简体   繁体   English

在更改显示设置中的字体大小时,Android TextSwitcher大小会增加

[英]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.

相关问题 从系统设置更改字体大小时,Android TextView(大小设置为 sp)不会改变大小 - Android TextView(size set as sp) is not changing size when font size is changed from system settings Android 应用程序中 TextView 的字体大小随着从本机设置更改字体大小而变化 - Font size of TextView in Android application changes on changing font size from native settings Android:根据手机的当前设置更改WebView的字体大小和字体样式 - Android: Changing a WebView's font size and font style depending on the phone's current settings Android应用程序字体大小根据设置中定义的字体大小而变化 - Android applications font size changes according to the defined font size in settings TextSwitcher 的自动调整文本视图大小 - Auto Size TextView for TextSwitcher 覆盖android系统设置的字体大小 - Override the font size of the android system settings 更改Android应用程序的显示大小 - changing display size of android app 自定义字体大小设置 - Custom font size settings Android 应用程序在更改字体大小时崩溃 - Android App crashing on changing the font size Android 版 Google Chrome 上的字体大小显示问题 - Font size display issue on Google Chrome for Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM