2015-09-04 62 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

好了,有你的點... ...讓我試試這個:) –