2015-09-04 98 views

回答

0

在Android中创建视图后,转变作风,不支持。那就是你不能动态地为视图设置样式。但是你可以做的是在xml中创建这个视图,只在xml中设置你想要的样式,并且当你想要显示一个视图时,你就可以膨胀它。 例如

<?xml version="1.0" encoding="utf-8"?> 
    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="This is a template" 
    style="@style/my_style" /> 

无论您想去哪里,以现在用充气TIS观点,

TextView myText = (TextView)getLayoutInflater().inflate(R.layout.tvtemplate, null); 
+0

好了,有你的点... ...让我试试这个:) –