Android - set TextView TextStyle programmatically?

前端 未结 11 633
南旧
南旧 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:48

    You may try this one

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    textView.setTextAppearance(R.style.Lato_Bold);
                } else {
                    textView.setTextAppearance(getActivity(), R.style.Lato_Bold);
                }
    

提交回复
热议问题