How to assign text size in sp value using java code

后端 未结 11 2044
無奈伤痛
無奈伤痛 2020-12-04 05:14

If I assign an integer value to change a certain text size of a TextView using java code, the value is interpreted as pixel (px).

Now does

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 06:12

    By default setTextSize, without units work in SP (scales pixel)

    public void setTextSize (float size) 
    Added in API level 1
    Set the default text size to the given value, interpreted as "scaled pixel" units. This 
    size is adjusted based on the current density and user font size preference.
    

提交回复
热议问题