One way to achieve this can be as follows.
Create style xml in your res/values/ directory.
Now define style , but you want it. Using this method, it will change all Views where style is applied to that particular style .
Here is my example that I tested:
<?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>
Now add style to your top level layout in xml that defines the children for your ExpandableListView . For example, here is my child (note the style in my LinearLayout ):
<?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>
This should change the color of all your children to green, I believe. You can change style to whatever you want. There is some excellent documentation that I have linked that should help you.
source share