getDimension()/getDimensionPixelSize() - mutliplier issue

后端 未结 5 1087
悲哀的现实
悲哀的现实 2021-02-07 06:07

So I have android 2.3.5 device which is NORMAL/HDPI. I have a dimens.xml in my project:

...
    20sp         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 06:32

    If someone else needs this :

    To address the double scaling problem Stan show when using getDimensionPixelSize with TextView.setTextSize :

    You can use the alternate version of setTextSize where you can specify the unit like this :

    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.title));
    

提交回复
热议问题