Change Theme.Dialog to look like Theme.Light.Dialog in Android-ThrowExceptions

Exception or error:

There is no Theme.Light.Dialog to use with the rest of my project that is using Theme.Light.

How can I change Theme.Dialog to look like a Theme.Light version of Dialog.

I know that I must overwrite sections of Theme.Dialog in styles.xml as below. What items should I overwrite with which values?

<style name="dialog_light" parent="@android:style/Theme.Dialog">
    <item name="android:???????"></item>
    <item name="android:???????"></item>
</style>

I could just make the background that light white grey, but the buttons, spinners etc are also different on the light theme to look better on the light background.

EDIT

Looks like I got it working.

<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>

<style name="dialog_light" parent="@android:style/Theme.Dialog">
    <item name="@android:windowBackground">@color/whitegrey</item>
    <item name="@android:textColor">@color/black</item>        
</style>
How to solve:

Looks like I got it working.

<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>

<style name="dialog_light" parent="@android:style/Theme.Dialog">
    <item name="@android:windowBackground">@color/whitegrey</item>
    <item name="@android:textColor">@color/black</item>        
</style>

###

Further to the above, to avoid making up colors, I did this:

<!-- Makes a "light" equivalent of Theme.Dialog -->
<style name="dialog_light" parent="@android:style/Theme.Dialog">
    <item name="@android:background">@android:color/background_light</item>
    <item name="@android:textColor">@android:color/primary_text_light</item>    
</style>

###

This is good, thanks!
I just changed it a bit: when I run what you suggested, the entire screen is painted with the back color and the dialog does not look as it should (with the previous activity dimmed).

So instead of using

@android:windowBackground

just use

@android:background

Leave a Reply

Your email address will not be published. Required fields are marked *