TextView - setting the text size programmatically doesn't seem to work

前端 未结 7 1231
灰色年华
灰色年华 2020-12-12 17:49

I am using Eclipse Indigo, testing on 2 emulators(2.2 and 3.0).

the code below shows what I am testing now, however setting the text size reveals nothing on the scre

7条回答
  •  抹茶落季
    2020-12-12 18:07

    the method TextView.setTextSize(int unit , float size); takes two parameters .

    Try this :

    text.setTextSize(TypedValue.COMPLEX_UNIT_SP,14);
    

    refer this and this.

    UPDATE: Now the setTextSize(float size) will set the text size automatically in "scaled pixel" units. no need to mention the COMPLEX_UNIT_SP manually. Refer to the documentation.

提交回复
热议问题