通过XML文件的TextView粗体?


Answers:


473

我有一个项目,其中有以下内容TextView

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:text="@string/app_name"
    android:layout_gravity="center" 
/>

所以,我猜你需要使用 android:textStyle


我在库<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="20dp" android:paddingRight="20dp" android:text="@string/start" android:textAppearance="@style/PtSansNarrowFont" android:textColor="@color/white" /> style.xml中使用这种方式, <style name="PtSansNarrowFont" parent="android:TextAppearance"> <!-- Custom Attr--> <item name="fontPath">fonts/pt-sans_narrow.ttf</item> </style> 但未使用粗体
Prasad
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.