這樣可以實現的一個方法是以下幾點。
在您的res/values/
目錄中創建一個style
xml
。
現在定義你的style
然而你想要它。以這種方式使用時,它將更改所有Views
,其中style
應用於此特定style
。
這是我的例子,我有測試:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="backgroundTest" parent="@android:style/TextAppearance.Medium">
<item name="android:background">#00FF00</item>
</style>
</resources>
現在添加style
到您的頂層佈局定義兒童爲您ExpandableListView
的XML。例如,這裏是我的孩子(注意我LinearLayout
的style
):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/backgroundTest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/rightSideTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="25dp"
android:paddingLeft="50dp"
android:paddingTop="25dp" />
</LinearLayout>
這應該改變所有你的孩子綠色的顏色,我相信。您可以將style
更改爲任何您想要的。有一些很好的文檔可以幫助你。
'android:style =「@ style/mysubStyle」'? – Ronnie 2012-07-22 12:21:39
@ userSeven7s我應該在哪裏應用這種風格?如果我將它應用於ExpandableListView本身,那麼我假設整個樣式將被改變(包括第一和第二級)。我只需要風格第二級。 – 2012-07-22 12:37:56
你必須申請每個子級別的項目..當添加getview方法.. – Ronnie 2012-07-22 12:39:24