开发者

Android - text size on particular resolution - setting programatically

开发者 https://www.devze.com 2023-02-15 13:02 出处:网络
I am programming application, which will be used on various kinds of resolutions, but let\'s say, we would keep to the density. For medium, high and low I am setting it\'s own drawables, but it still

I am programming application, which will be used on various kinds of resolutions, but let's say, we would keep to the density. For medium, high and low I am setting it's own drawables, but it still doesn's solve my problem, so I am wondering, how to set values dependently on actual pixel screen 开发者_JS百科density in Java code?

In this time I have to in XML set smaller letters and smaller textviews to fit it into low resolution screen, on the other hand, high density screen is used from about 60% and text fields are too small. I am wondering if there is some way how to, during the start of the program, in some If loop find out, what the resolution is and then set layout_height and textSize for items I want.

Thanks

edit: Solved myself - http://developer.android.com/reference/android/util/DisplayMetrics.html


well before moving ahead to set the text size programatically, I recommend you to set the Textsize property's value in dip instead of px. it seems that you have marked the textsize value in px.

0

精彩评论

暂无评论...
验证码 换一张
取 消