Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 204
Rynardt Avatar asked Jun 06 '12 13:06

Rynardt


People also ask

How do I change the light theme in Android Studio?

Go to File > Settings, now under IDE settings click on appearance and select the theme of your choice from the dropdown. File > Import Settings , select the file or your choice and select ok a pop up to restart the studio will open up click yes and studio will restart and your theme will be applied.

How many styles of AlertDialog are there?

There are three kinds of lists available with the AlertDialog APIs: A traditional single-choice list. A persistent single-choice list (radio buttons) A persistent multiple-choice list (checkboxes)

What is AlertDialog builder in Android?

Alert Dialog shows the Alert message and gives the answer in the form of yes or no. Alert Dialog displays the message to warn you and then according to your response the next step is processed. Android Alert Dialog is built with the use of three fields: Title, Message area, Action Button.


2 Answers

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>
like image 96
Rynardt Avatar answered Sep 20 '22 08:09

Rynardt


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>
like image 43
Georgie Avatar answered Sep 21 '22 08:09

Georgie