getDimension()/getDimensionPixelSize() - mutliplier issue

后端 未结 5 1088
悲哀的现实
悲哀的现实 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:26

    Per the Supporting Different Screen Densities training, hdpi is 1.5x normal (mdpi) sizes. As getDimensionPixelSize takes this difference into account when converting into pixels, the returned value will be 1.5x your value in sp.

    Note that sp is also dependent on the user's preferred text size and can therefore change to be even larger than 1.5x your expected value.

提交回复
热议问题