Skip to content

Commit 7d65faf

Browse files
committed
fix resource loading
1 parent f511bf0 commit 7d65faf

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,32 @@ XML widget to create the Material Design Floating Action Button for Android Nati
1212

1313
## Usage
1414

15+
### For using with a custom resource
16+
1517
#### XML
1618
```XML
1719
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
1820
xmlns:FAB="nativescript-floatingactionbutton">
1921
<FAB:fab tap="fabTap"
20-
icon="ic_add_white"
22+
icon="res://ic_add_white"
2123
backColor="#ff4081"
2224
rippleColor="#f1f1f1"
2325
class="fab-button" />
2426
</Page>
2527
```
28+
### For using with an android built-in resource
29+
30+
#### XML
31+
```XML
32+
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
33+
xmlns:FAB="nativescript-floatingactionbutton">
34+
<FAB:fab tap="fabTap"
35+
icon="ic_menu_camera"
36+
backColor="#ff4081"
37+
rippleColor="#f1f1f1"
38+
class="fab-button" />
39+
</Page>
40+
```
2641

2742
#### CSS
2843
I recommend the following CSS styles.
@@ -59,4 +74,4 @@ Attribute to specify which icon to use for the FAB button, supports the same ima
5974

6075
### Contributors
6176

62-
- Lázaro Danillo [lazaromenezes](https://github.com/lazaromenezes)
77+
- L�zaro Danillo [lazaromenezes](https://github.com/lazaromenezes)

demo/app/main-page.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<StackLayout>
77
<grid-layout rows="auto, *" id="main-content">
88
<label text="Native FAB down there..." class="title" row="0" />
9-
9+
1010
<FAB:fab tap="fabTap"
1111
row="1"
12-
icon="ic_add_white"
12+
icon="res://ic_add_white"
1313
backColor="#ff4081"
1414
rippleColor="#f1f1f1"
1515
class="fab-button" />
1616
</grid-layout>
1717
</StackLayout>
18-
</Page>
18+
</Page>

fab.android.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232
if(this.icon){
3333
iconDrawable = null;
3434

35-
if(ImageSource.isFileOrResourcePath(this.icon))
35+
if(ImageSource.isFileOrResourcePath(this.icon)){
3636
iconDrawable = ImageSource.fromFileOrResource(this.icon);
37+
this._android.setImageBitmap(iconDrawable.android);
38+
}
3739
else{
3840
var drawableId = android.content.res.Resources.getSystem().getIdentifier(this.icon, "drawable", "android");
3941
iconDrawable = android.content.res.Resources.getSystem().getDrawable(drawableId);
40-
}
41-
42-
if(iconDrawable != null)
4342
this._android.setImageDrawable(iconDrawable);
43+
}
4444
}
4545

4646
var that = new WeakRef(this);

0 commit comments

Comments
 (0)