android xml设置roboto字体,Android设置Roboto字体用粗体,斜体,常规,…(类似于自定义字体系列)...
我知道在
Android應(yīng)用程序中以編程方式設(shè)置自定義字體.
有沒(méi)有辦法為自定義字體(資產(chǎn))加載字體,Android框架將使用基于粗體,斜體等的正確文件?
例如,現(xiàn)在我正在嘗試將Roboto字體設(shè)置為某些TextView
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Roboto/Roboto-Regular.ttf");
textView.setTypeface(typeface);
它工作正常.但由于我將xml布局中的TextView設(shè)置為粗體,因此文本不會(huì)加粗
android:id="@+id/my_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="50dp"
android:textStyle="bold"
android:gravity="center"
android:text="@string/my_text"
android:textColor="@color/my_foreground"
android:textSize="24dp" />
如何從資產(chǎn)中正確加載字體,這將起作用?
textView.setTypeface(typeface, Typeface.BOLD);
在我的資產(chǎn)目錄中,只有一個(gè)“字體系列”
Roboto-Black.ttf
Roboto-BlackItalic.ttf
Roboto-Bold.ttf
Roboto-BoldCondensed.ttf
Roboto-BoldCondensedItalic.ttf
Roboto-BoldItalic.ttf
Roboto-Condensed.ttf
Roboto-CondensedItalic.ttf
Roboto-Italic.ttf
Roboto-Light.ttf
Roboto-LightItalic.ttf
Roboto-Medium.ttf
Roboto-MediumItalic.ttf
Roboto-Regular.ttf
Roboto-Thin.ttf
Roboto-ThinItalic.ttf
如何在一個(gè)字體/系列中加載所有字體?
總結(jié)
以上是生活随笔為你收集整理的android xml设置roboto字体,Android设置Roboto字体用粗体,斜体,常规,…(类似于自定义字体系列)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: opengl2 vtk 编译_编译和使用
- 下一篇: Hive分析窗口函数(五) GROUPI