Textview adaptive size for Android

Setting the default font size of textview is very important to the good-looking degree of the UI interface. The text set on the small screen is too large or the text set on the large screen is too small, resulting in the unsightly UI

Now let's learn the textview control with adaptive size, that is, when the text length changes, the text size will change accordingly to ensure that it is displayed in one line

The implementation relies on third-party class libraries

Third party sources:

https://github.com/grantland/android-autofittextview

Just like using textview normally, you only need to set the textview label to be adaptive to < me. Grantland. Widget. Autofittextview / >

Note: it must be set as a single line. Negative cannot display the effect

android:singleLine="true"

Layout file:

string.xml

activity

effect:

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>