2016-07-22 259 views
12

如果我定義我TextView爲:TextView的風格和android:textAppearance屬性有什麼區別?

<TextView 
     style="@android:style/TextAppearance.DeviceDefault.Large" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" /> 

它基本上是一樣的做:

<TextView 
     android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" /> 

我知道style是某種更廣泛的資格賽(即一個不能設置所有屬性在android:textAppearance),但它提出了一個問題:爲什麼要麻煩?使用android:textAppearance優於style有什麼優勢?

回答

1

只能每次觀看一個樣式屬性,但使用TextAppearance可以讓你在本質上使用受限制的組文本相關屬性的定義樣式。您可以在一個視圖中同時使用樣式和TextAppearance。

相關問題