Android Question [Solved] Is there any appcompat background property?

Michael2150

Member
Licensed User
Hi so i've been using this piece of code in my manifest:
B4X:
SetApplicationAttribute(android:theme, "@style/Theme.AppCompat")
SetApplicationAttribute(android:theme, "@style/my_blue_theme")

'================= Appcompat library App colors can be set here =============
CreateResource(values, theme.xml,
<resources>
    <style name="my_blue_theme" parent="@style/Theme.AppCompat">
        <item name="colorPrimary">     #22428f </item>
        <item name="colorPrimaryDark"> #11317D </item>
        <item name="colorAccent">      #22428f </item>
    </style>
</resources>)
And i was wondering is there some kind of
B4X:
<item name="background">  #000000 </item>"
line I could use to set the default background of the activity.
Thanks in advance.
 

Michael2150

Member
Licensed User
When I use " android:windowBackground " I get the following error when compiling.

Failed to generate resource table for split ''
res\values\theme.xml:7: error: Error: Color types not allowed (at 'android:windowBackground' with value ' #000000 ').
 

Michael2150

Member
Licensed User
Okay so I did a bit of research about the "android:windowBackground" item and I found the following:

The value of windowBackground must be a referenced color:
B4X:
<item name="android:windowBackground">@color/red</item>
but for backgroundColor you can use literals:
B4X:
<item name="android:colorBackground">#ff0000</item>
So I made some changes to my manifest and ended up with this working code:
B4X:
SetApplicationAttribute(android:theme, "@style/Theme.AppCompat")
SetApplicationAttribute(android:theme, "@style/blue_theme")

'================= Appcompat library App colors can be set here =============
CreateResource(values, colors.xml,
<resources>
   <color name="colorPrimary">        #FF22428F</color>
   <color name="colorPrimaryDark">    #FF11317D</color>
   <color name="colorAccent">        #FF22428F</color>
   <color name="windowBackground">    #FFFFFFFF</color>
</resources>
)
CreateResource(values, theme.xml,
<resources>
    <style name="blue_theme" parent="@style/Theme.AppCompat">
        <item name="colorPrimary">                @color/colorPrimary</item>
        <item name="colorPrimaryDark">            @color/colorPrimaryDark</item>
        <item name="colorAccent">                @color/colorAccent</item>
        <item name="android:windowBackground">    @color/windowBackground</item>
    </style>
</resources>)
'============================================================================
Thanks Erel for the help.
 
Top