文本的大小将通过以下方式在我的应用程序中设置(res/values/dimens.xml):
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<dimen name="size_font">28sp</dimen>
</resources>
然后将创建一个样式(res/values/styles-font.xml):
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyFont">
<item name="android:textStyle">normal</item>
<item name="android:textColor">@color/grey_33</item>
<item name="android:textSize">@dimen/size_font</item>
<item name="android:ellipsize">end</item>
<item name="android:lines">1</item>
</style>
</resources>
稍后在布局中:
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/MyFont" />
问题:
如果我在系统首选项(设置 --> 显示 --> 字体大小)中更改字体大小,我的应用程序中的文本大小不会改变。
是什么让我错了?有什么解决办法?