How is the DialogPreference style with a custom theme?

In my application, I used Theme.Holo and Theme.Holo.Light without any problems. When the Holo theme is used, and I click on DialogPreference / ListPreference, the popup dialog also has Holo theme. The same goes for Holo.Light. But when PreferencesActivity takes shape with my special theme, which is obtained from Holo.Light, all dialogs are related to Holo.Light. I think that in my topic I am missing something. Can anyone help me? Thank you very much!

Here is my theme code:

<?xml version="1.0" encoding="utf-8"?> <!-- Generated with http://android-holo-colors.com --> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="GreenTheme" parent="android:Theme.Holo.Light"> <item name="android:editTextBackground">@drawable/edit_text_holo_light</item> <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewGreenTheme</item> <item name="android:listChoiceIndicatorMultiple">@drawable/btn_check_holo_light</item> <item name="android:listChoiceIndicatorSingle">@drawable/btn_radio_holo_light</item> <item name="android:buttonStyle">@style/ButtonGreenTheme</item> <item name="android:imageButtonStyle">@style/ImageButtonGreenTheme</item> <item name="android:dropDownSpinnerStyle">@style/SpinnerGreenTheme</item> <item name="android:tabWidgetStyle">@style/TabWidgetGreenTheme</item> <item name="android:progressBarStyleHorizontal">@style/ProgressBarGreenTheme</item> <item name="android:seekBarStyle">@style/SeekBarGreenTheme</item> <item name="android:buttonStyleToggle">@style/ToggleGreenTheme</item> <item name="android:listChoiceBackgroundIndicator">@drawable/list_selector_holo_light</item> <item name="android:activatedBackgroundIndicator">@drawable/activated_background_holo_light</item> <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item> <item name="android:actionBarStyle">@style/ActionBar.Solid.Greenactionbar</item> <item name="android:buttonBarButtonStyle">@style/ButtonBarButtonStyleGreenTheme</item> <item name="android:preferenceStyle">@style/TimePickerDialogFragmentGreen</item> </style> <style name="TimePickerDialogFragmentGreen" parent="@android:style/Theme.Holo.Light.Dialog"> <item name="android:editTextBackground">@drawable/edit_text_holo_light</item> <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewGreenTheme</item> <item name="android:listChoiceIndicatorMultiple">@drawable/btn_check_holo_light</item> <item name="android:listChoiceIndicatorSingle">@drawable/btn_radio_holo_light</item> <item name="android:buttonStyle">@style/ButtonGreenTheme</item> <item name="android:imageButtonStyle">@style/ImageButtonGreenTheme</item> <item name="android:dropDownSpinnerStyle">@style/SpinnerGreenTheme</item> <item name="android:tabWidgetStyle">@style/TabWidgetGreenTheme</item> <item name="android:progressBarStyleHorizontal">@style/ProgressBarGreenTheme</item> <item name="android:seekBarStyle">@style/SeekBarGreenTheme</item> <item name="android:buttonStyleToggle">@style/ToggleGreenTheme</item> <item name="android:listChoiceBackgroundIndicator">@drawable/list_selector_holo_light</item> <item name="android:activatedBackgroundIndicator">@drawable/activated_background_holo_light</item> <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item> <item name="android:actionBarStyle">@style/ActionBar.Solid.Greenactionbar</item> <item name="android:buttonBarButtonStyle">@style/ButtonBarButtonStyleGreenTheme</item> </style> </resources> 
+4
source share
2 answers

I found this rather unformatted but otherwise good answer .

The bottom line is that the DialogPreference AlertDialog created without the theme parameter , which means they apply to what ever the android:alertDialogTheme points to.

So, I expanded my topic as follows:

 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light"> <item name="colorPrimary">@color/yellow_500</item> <item name="colorPrimaryDark">@color/yellow_a700</item> <item name="colorAccent">@color/purple_400</item> <item name="android:alertDialogTheme">@style/DialogTheme</item> </style> <style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog"> <item name="colorPrimary">@color/yellow_500</item> <item name="colorPrimaryDark">@color/yellow_a700</item> <item name="colorAccent">@color/purple_400</item> <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item> </style> </resources> 

colorPrimary , colorPrimaryDark and colorAccent in AppTheme were the colors I wanted to apply to the dialog box.

Note that I needed android:windowMinWidthMinor so that the dialog does not collapse horizontally.

+2
source

I have clarifying questions, but I can not ask them because of the low speed. So:
1. Does your first style work correctly?
2.Are you sure that the @android: style / Theme.Holo.Light.Dialog theme has all the elements you specified in TimePickerDialogFragmentGreen? For instance:

 <item name="android:tabWidgetStyle"> @style/TabWidgetGreenTheme</item> 


3. Have you tried the idea suggested by Luksprog

And finally: I used something like this to create my own style for my EditTexts:

  <style name="EditTextStyle" parent="@style/Indents"> <item name="android:textColor">@android:color/black</item> <item name="android:background">@android:color/white</item> <item name="android:textColorHint">@android:color/darker_gray</item> <item name="android:textSize">14sp</item> </style> <style name="Indents" parent="@style/Margins"> <item name="android:paddingBottom">@dimen/activity_vertical_padding</item> <item name="android:paddingTop">@dimen/activity_vertical_padding</item> </style> <style name="Margins"> <item name="android:layout_marginTop">@dimen/activity_vertical_margin </item> <item name="android:layout_marginBottom">@dimen/activity_vertical_margin </item> <item name="android:layout_marginLeft">@dimen/activity_horizontal_margin </item> <item name="android:layout_marginRight">@dimen/activity_horizontal_margin </item> </style> 
0
source

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


All Articles