在我的Android应用中,我在不同的 Activity 中使用了各种自定义主题,所有这些主题都运行良好。所有这些主题均对按钮,编辑控件等使用相同的自定义样式。
我的首选项使用标准的“首选项” Activity ,我通过 list 以XML和样式定义了这些首选项。
但是,当我具有导致启动警报对话框的首选项(例如ListPreference)时,该对话框使用标准按钮。它似乎确实在EditTextPreference中使用了我自定义的EditText样式...,但是没有使用我的背景或文本颜色。
有人知道为什么会这样吗?
一些代码:
样式:
<style name="Theme.Prefs" parent="@android:style/Theme.Holo.Light">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:buttonStyle">@style/CustomButtonStyle</item>
<item name="android:editTextStyle">@style/CustomEditTextStyle</item>
</style>
<style name="CustomButtonStyle" parent="@android:style/Widget.Holo.Button">
<item name="android:background">@drawable/custom_button</item>
<item name="android:textSize">@dimen/dialog_text_size_normal</item>
<item name="android:textColor">@color/dialog_control_colour</item>
</style>
<style name="CustomEditTextStyle" parent="@android:style/Widget.Holo.EditText">
<item name="android:background">@drawable/custom_textfield</item>
<item name="android:textColor">@color/dialog_control_colour</item>
<item name="android:textSize">@dimen/dialog_text_size_normal</item>
</style>
并在 list 中:
<activity
android:name="com.breadbun.prefs.MainPreferencesActivity"
android:theme="@style/Theme.Prefs"
android:screenOrientation="portrait">
</activity>
最佳答案
要自定义alertDialog,您需要在主主题中添加第二行,然后以所需的方式自定义DialogStyle。
<style name="AppTheme" parent="android:Theme.Material">
<item name="android:alertDialogTheme">@style/DialogStyle</item>
</style>
<style name="DialogStyle" parent="android:Theme.Material.Dialog.Alert">
</style>
关于android - 在Android列表首选项中设置自定义主题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16511715/