简体   繁体   中英

Android: Set custom background color for layout using custom theme

i generated custom theme for my app on: http://jgilfelt.github.io/android-actionbarstylegenerator/

And now i would like to add custom color for background of all activities ale fragments in the app.

I tried to do by this way, but it colors also backgroud of text views and images too (which i don't need).

How can i do it to avoid set custom background of the each activity or fragment layout ?

Thanks for any advice

   <style name="Theme.Custom" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarItemBackground">@drawable/selectable_background_custom</item>
        <item name="android:popupMenuStyle">@style/PopupMenu.Custom</item>
        <item name="android:dropDownListViewStyle">@style/DropDownListView.Custom</item>
        <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Custom</item>
        <item name="android:actionDropDownStyle">@style/DropDownNav.Custom</item>
        <item name="android:actionBarStyle">@style/ActionBar.Solid.Custom</item>
        <item name="android:actionModeBackground">@drawable/cab_background_top_custom</item>
        <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_custom</item>
        <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Custom</item>
        <item name="android:background">@color/custom_white</item>

                <!-- Light.DarkActionBar specific -->
        <item name="android:actionBarWidgetTheme">@style/Theme.Custom.Widget</item>

    </style>

You can try adding windowBackground item to your theme, this should color all your activities' backgrounds.

<resources>  
  <style name="MyTheme" parent="@android:style/Theme.Light">    
    <item name="android:windowBackground">@color/background</item>  
  </style>
</resources>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM