Android:在运行时设置TextView样式

Moh*_*kab 12 android

有没有人知道如何TextView在运行时设置样式:

这样的事情

myTextView.setStyle(R.style.mystyle);
Run Code Online (Sandbox Code Playgroud)

小智 25

使用setTextApparence和你的风格非常简单

 myTextView.setTextAppearance(getApplicationContext(), R.style.boldText);
Run Code Online (Sandbox Code Playgroud)


Rya*_*rad 3

您必须手动设置您更改的样式的每个元素,据我所知,无法在运行时设置样式。

myTextView.setTextAppearance
myTextView.setTextSize
myTextView.setTextColor
Run Code Online (Sandbox Code Playgroud)