Android - set TextView TextStyle programmatically?

前端 未结 11 621
南旧
南旧 2020-12-02 05:04

Is there a way to set the textStyle attribute of a TextView programmatically? There doesn\'t appear to be a setTextStyle() method.

11条回答
  •  时光取名叫无心
    2020-12-02 05:56

    textview.setTypeface(Typeface.DEFAULT_BOLD);
    

    setTypeface is the Attribute textStyle.

    As Shankar V added, to preserve the previously set typeface attributes you can use:

    textview.setTypeface(textview.getTypeface(), Typeface.BOLD);
    

提交回复
热议问题