[英]Android: Set custom background color for layout using custom theme
i generated custom theme for my app on: http://jgilfelt.github.io/android-actionbarstylegenerator/ 我在以下位置为我的应用生成了自定义主题: 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. 您可以尝试将windowBackground项目添加到主题,这应该为所有活动的背景着色。
<resources>
<style name="MyTheme" parent="@android:style/Theme.Light">
<item name="android:windowBackground">@color/background</item>
</style>
</resources>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.