这是我的主题代码:
<?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>解决方法 我找到了 this rather unformatted but otherwise nice answer.
要点是DialogPreferences是在没有the theme
parameter的情况下创建的AlertDialogs,这意味着它们应用了androID:alertDialogtheme所指向的主题.
所以我扩展了这样的主题,以对话为主题:
<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>
Apptheme中的colorPrimary,colorPrimaryDark和colorAccent也是我想要应用于对话框的颜色.
请注意,我需要androID:windowMinWIDthMinor来防止对话框水平折叠.
总结以上是内存溢出为你收集整理的android – 如何使用自定义主题设置DialogPreference样式?全部内容,希望文章能够帮你解决android – 如何使用自定义主题设置DialogPreference样式?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)