How to set include background color in android

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.


You can not give a background color into include tag.

Why ?

Its obvious , if you could able to give the background color to include tag then it would be all messed up with your include color and another color which might be applied to that layout which has already included .

However, you can also override all the layout parameters (any android:layout_* attributes) of the included layout's root view by specifying them in the tag. (quoting from https://developer.android.com/training/improving-layouts/reusing-layouts.html#Includ )