I am trying to get all of my activities to have a custom theme style that should look like this:
I found that the latest version of Android Studio expect that the parent for the style needs to be Theme.AppCompat. Also, it is good style to create a colors.xml file in the values directory (with named color elements between the resource tags). Put your RGB values as values to the named color elements. Reference them in your styles with @color/.
<!--colors.xml in values folder-->
<resources>
<color name="color1">#ffb62a23</color>
<color name="color2">#ffedeba6</color>
<color name="color3">#00ff00</color>
</resources>
<!--style tags -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowBackground">@color/color2</item>
<item name="android:textColorPrimary">@color/color1</item>
<item name="android:textColorSecondary">@color/color2</item>
<item name="android:textColorTertiary">@color/color3</item>
</style>
The key to solving the problem was changing android:windowBackground
in the theme to the following:
<item name="android:windowBackground">@drawable/default_background</item>
Notice that I am no longer using @color
, but simply a @drawable
, the xml for which is below:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/background"/>
</shape>
It seems that some devices do not support accepting a color for this element.