これを実現する 1 つの方法は、次のとおりです。
ディレクトリに を作成します。style
xml
res/values/
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>
次に、 の子を定義する xml の最上位レイアウトに を追加style
しますExpandableListView
。たとえば、これが私の子供です ( my の に注意しstyle
てください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>
これにより、すべての子供の色が緑に変わるはずです。を好きなように変更できstyle
ます。リンクした素晴らしいドキュメントがいくつかあります。