Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set include background color in android

How to set background color on an include tag in Android? This does not work:

 <include
 android:id="@+id/list_item_section_text"
 android:layout_width="fill_parent"
 android:layout_height="match_parent"
 layout="@android:layout/preference_category"
 android:background="%MY_BACKGROUND%"/>
like image 584
Mr. Avatar asked Feb 26 '15 14:02

Mr.


1 Answers

If you are not "too-deep-view-tree-paranoia" type of guy, you can wrap your include in FrameLayout:

<FrameLayout
    android:id="@+id/list_item_section_text"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:background="%YOUR_BACKGROUND%">

        <include layout="@android:layout/preference_category"/>

</FrameLayout>

EDIT: Of course, don't forget to remove android:background from your preference_category.xml layout first.

like image 135
Sevastyan Savanyuk Avatar answered Oct 11 '22 19:10

Sevastyan Savanyuk