Pro Android with Kotlin


CHAPTER 9: User Interface


Download 5.42 Mb.
Pdf ko'rish
bet171/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   167   168   169   170   171   172   173   174   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile



204
CHAPTER 9: User Interface
To add fonts with different font styles, say you have the fonts myfont_regular.ttf,
myfont_bold.ttf , myfont_italic.ttf, and myfont_bold_italic.ttf inside the font resource 
folder. Add the file myfont.xml by choosing New ➤ Font resource file. In this file write the 
following:

xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto">
android:font
app:font
android:fontWeight="400"
app:fontWeight="400"
android:font="@font/myfont_regular"
app:font="@font/myfont_regular"/>
android:font
app:font
android:fontWeight="700"
app:fontWeight="700"
android:font="@font/myfont_bold"
app:font="@font/myfont_bold"/>
android:font
app:font
android:fontWeight="400"
app:fontWeight="400"
android:font="@font/myfont_italic"
app:font="@font/myfont_italic"/>
android:font
app:font
android:fontWeight="700"
app:fontWeight="700"
android:font="@font/myfont_bold_italic"
app:font="@font/myfont_bold_italic"/>
Ignore Android Studio’s version warning; for compatibility, all attributes use a standard and 
additionally a compatibility namespace.
Then you can use the name of this XML file, without the suffix, for UI views inside the 
android:fontFamily attribute.
android:fontFamily="@font/myfont"
android:text
/>
As textStyle you could now also use italic or bold or bold|italic.



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   167   168   169   170   171   172   173   174   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling