这样可以实现的一个方法是以下几点。
在您的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