有没有办法以编程方式设置TextView
的textStyle
属性?似乎没有一种方法.
要明确的是,我不是在谈论视图/小部件样式!我说的是:
<TextView
android:id="@+id/my_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World"
android:textStyle="bold" />
有没有办法以编程方式设置TextView
的textStyle
属性?似乎没有一种方法.
要明确的是,我不是在谈论视图/小部件样式!我说的是:
<TextView
android:id="@+id/my_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World"
android:textStyle="bold" />
textview.setTypeface(Typeface.DEFAULT_BOLD);
setTypeface是textStyle的属性.
添加Shankar V后,要保留之前设置的字体属性,可以使用:
textview.setTypeface(textview.getTypeface(), Typeface.BOLD);