Skip to content

Commit 422b1f8

Browse files
committed
add md info
1 parent 88f1210 commit 422b1f8

File tree

6 files changed

+21
-52
lines changed

6 files changed

+21
-52
lines changed
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
The title of the ActionBar can be easily set by its corresponding property - `title`. You can additionally set an icon to use in your ActionBar on Android with the `icon` property.
1+
### Icon Fonts in ActionBar
22

3-
Here’s what a basic usage of the `title` and `icon` properties looks like:
4-
<snippet id='action-bar-title-icon-html'/>
3+
Using the `font://` prefix, you can load a resource in the ActionItem while setting up an icon code provided by an icon font. By setting up this prefix, a new image will be generated, which will be set as an ActionItem's `icon` resource. While using this functionality, we need to specify the `font-size`, which will calculate the size of the generated image base on the device's dpi.
54

6-
The icon can only be set in Android platform. It is hidden by default, but you can explicitly control its visibility with the `android.iconVisibility' property.
7-
8-
Furthermore, the title can be customized by placing a content component (button, label, layout-components, etc.) directly in the ActionBar.
5+
<snippet id='actionbar-icon-fonts-html'/>
6+
<snippet id='actionbar-icon-fonts-css-ng'/>
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
/* >> action-bar-icon-fonts-css-ng */
1+
/* >> actionbar-icon-fonts-css-ng */
22
.font-awesome {
33
font-family: "Font Awesome 5 Free", "fa-regular-400";
44
}
5-
/* << action-bar-icon-fonts-css-ng */
5+
66
.font-size {
77
font-size: 48;
8-
width: 48;
9-
height: 48;
108
}
11-
9+
/* << actionbar-icon-fonts-css-ng */
1210
.color {
1311
color: blue;
1412
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<StackLayout sdkToggleNavButton>
2-
<!-- >> action-bar-icon-fonts-html -->
2+
<!-- >> actionbar-icon-fonts-html -->
33
<ActionBar title=" NativeScript" android.icon="res://icon" android.iconVisibility="always">
44
<!-- >> (hide) -->
55
<NavigationButton text="Back" visibility="collapsed" ></NavigationButton>
@@ -8,5 +8,5 @@
88

99
<ActionItem icon="font://&#xF141;" style="font-family:'Font Awesome 5 Free', 'fa-regular-400';" class="font-size color" ios.position="right"></ActionItem>
1010
</ActionBar>
11-
<!-- << action-bar-icon-fonts-html -->
11+
<!-- << actionbar-icon-fonts-html -->
1212
</StackLayout>
Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
1-
### Create Image via HTML
2-
The `src` property can accept local and remote paths.
3-
It can also accept paths and `ImageSource` instances bind via code behind.
4-
<snippet id='creating-image-html'/>
1+
### Icon Fonts in Image
52

6-
### Create Image dynamically via TypeScript
7-
<snippet id='creating-image-code'/>
3+
Using the `font://` prefix, you can load a resource image while setting up an icon code provided by an icon font. By setting up this prefix, a new image will be generated, which will be set as an ImageView resource. While using this functionality, we need to specify the `font-size`, which will calculate the size of the generated image base on the device's dpi. For further configuration on size of the displayed image, we can config the view's `width` and `height` properties.
84

9-
### Background Image via CSS
10-
Use property `background-image` to apply image via CSS.
11-
<snippet id='css-load-background'/>
12-
<snippet id='load-image-css'/>
13-
14-
### Image with ImageSource from Base64 String
15-
Convert an image to and from Base64 encoded string using `toBase64String` and `fromBase64` methods.
16-
Then create an `ImageSource` instance and bind it to the `src` property of `Image`.
17-
<snippet id='creating-img-from-base'/>
18-
<snippet id='load-image-base-html'/>
19-
20-
### Setting image stretching
21-
22-
The stretch functionality allows us to describe how content is resized to fill its allocated space.
23-
The available options for this property are as follow:
24-
25-
* `none` - the image preserves its original size
26-
* `fill` - the image is resized to fill the destination dimensions. In this case, the aspect ratio is not preserved.
27-
* `aspectFit` - the image is resized to fit the destination dimensions while it preserves its native aspect ratio. If the aspect ratio of the destination rectangle differs from the image, the image will be clipped to fit in the destination.
28-
* `aspectFill` - the image is resized to fill in the destination dimensions while it preserves its native aspect ratio.
29-
30-
The default value for this property is `aspectFit`.
31-
32-
<snippet id='image-stretch'/>
33-
34-
In the above sample code, we set up the Image `stretch` property to `none`. This means that the image will be shown on the screen with its original size.
5+
<snippet id='image-icon-fonts-html'/>
6+
<snippet id='image-icon-fonts-css-ng'/>
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
/* >> css-image-icon-fonts */
21
Image {
32
height: 60;
43
margin: 16;
54
width: 60;
65
}
6+
/* >> image-icon-fonts-css-ng */
77
.font-awesome {
88
font-family: "Font Awesome 5 Free", "fa-regular-400";
99
}
1010

1111
.font-size {
1212
font-size: 96;
1313
}
14-
14+
/* << image-icon-fonts-css-ng */
1515
.color {
1616
color: blue;
1717
}
18-
/* << css-image-icon-fonts */
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<ScrollView sdkExampleTitle sdkToggleNavButton>
2+
<!-- >> image-icon-fonts-html -->
23
<GridLayout rows="*, *, *" columns="*, *" height="300" verticalAlignment="middle">
3-
<!-- font family only -->
4+
45
<Image row="0" col="0" src="font://&#xF2b9;" class="font-awesome"></Image>
5-
<!-- font family + font size -->
6+
67
<Image row="0" col="1" src="font://&#xF557;" class="font-awesome font-size"></Image>
7-
<!-- font family + color -->
8+
89
<Image row="1" col="0" src="font://&#xF433;" style="font-family: 'Font Awesome 5 Free', 'fa-regular-400';" class="font-awesome color"></Image>
9-
<!-- font family + font size + color -->
10+
1011
<Image row="1" col="1" src="font://&#xF240;" class="font-awesome font-size color"></Image>
1112
</GridLayout>
13+
<!-- << image-icon-fonts-html -->
1214
</ScrollView>

0 commit comments

Comments
 (0)