How to apply a light theme for activity and keep a dark theme for dialogs at the same time?

Is there a way that I could apply my own style for PreferenceActivity that inherits from Theme.Sherlock.Light or Theme.Light and preserves the dark style for preferenceDialog and AlertDialogs? Can I easily exclude dialogs from the application of light style? if there are no attributes, what should I set and what are the default color options used in the separators, the text is active, inactive, titles and subtitles, etc. in an easy topic? Thanks.

+4
source share
1 answer

I solved this by changing the theme of activity to light, and then I programmatically set the theme of the warning dialog to one of the dark Android built-in styles:

this.setTheme(android.R.style.Theme_Holo_Dialog); 

Since the PreferenceDialog inherits from Dialog, it also sets this theme for all PreferenceDialogs. To be more specific and add style to a specific dialog, you can use ContextThemeWrapper, as used in Dialog.java in the android source:

 builder = new AlertDialog.Builder(new ContextThemeWrapper(this, android.R.style.Theme_DeviceDefault_Dialog)) 
+4
source

Source: https://habr.com/ru/post/1438539/


All Articles