[英]Android TextSwitcher size increasing on changing the font size in the display settings
In my app, i have set fixed font size for all the text elements. 在我的应用程序中,我为所有文本元素设置了固定的字体大小。 And for a TextSwitcher that i am using, i am setting the font size like this.
对于我正在使用的TextSwitcher,我正在这样设置字体大小。
altitudeSwitcher = (TextSwitcher) findViewById(R.id.altitude);
altitudeSwitcher.setFactory(new ViewFactory() {
@Override
public View makeView() {
GradientColor gd = Gradients.AllGradients().get(2);
TextView t = new TextView(getApplicationContext());
t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
t.setTextSize(50);
t.setTextColor(gd.getTextColor());
return t;
}
});
But on changing the font size to huge in display settings, it increases a lot in size. 但是在将字体大小更改为较大的显示设置时,它会增加很多大小。 How can i set the font size fixed ?
如何设置固定的字体大小?
That was a silly doubt. 这是一个愚蠢的疑问。 Found it out.
找到了。 I had to set the unit too like this
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 50);
我也必须像这样设置单位
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 50);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.