[英]How to set font size globally and managed it by user
I want user to use SeekBar to choose the font size and apply it to whole app. 我希望用户使用SeekBar选择字体大小并将其应用于整个应用程序。 I don't want to extend base classes eg TextView.
我不想扩展基类,例如TextView。 I'm thinking something like in styles.xml set font size.
我在想像在styles.xml中设置字体大小。
<item name="android:textSize">X</item>
Where "X" is a font size load from SharedPreferences. 其中“ X”是从SharedPreferences中加载的字体大小。 Is this even possibile?
这甚至可能吗? Also I want that text will change dynamical in app.
我也希望文本在应用程序中能够动态变化。 So if user select with SeekBar font size to eg 20dp.
因此,如果用户选择SeekBar字体大小为20dp。 It will change instantly.
它将立即改变。 I found this .
我发现了这个 。 But there is exemple with predefined font size and this is not I'm looking for.
但这是一个预定义字体大小的示例,这不是我想要的。
No, you can't dynamically change values from resource files. 不,您不能动态更改资源文件中的值。 This is how I would do it:
这就是我要做的:
SharedPreferences
. SharedPreferences
。 SharedPreferences
and apply it to all TextViews
SharedPreferences
加载值并将其应用于所有TextViews
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.