kov*_*c-s 4 android android-alertdialog android-styles
所以我想改变我的alertdialogs强调颜色,我把它添加到我的styles.xml中
<style name="AppTheme.AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这进入我的基本风格:
<item name="android:alertDialogTheme">@style/AppTheme.AlertDialogTheme</item>
Run Code Online (Sandbox Code Playgroud)
颜色改变了,很酷,但现在我的所有对话框都变小了.如何在更改颜色时保留尺寸?
通过查看google iosched代码,alertdialog主题需要从Theme.AppCompat.Light.Dialog.Alert继承而不仅仅是Theme.AppCompat.Light.Dialog.
两个警告.一,结果比以前更宽,但至少它不像包装内容那么窄.二,这在pre-L设备上引起了奇怪的行为.最终,我最终创建了所有警报
AlertDialog.Builder dialog = new AlertDialog.Builder(context,
R.style.Theme_AppCompat_Light_Dialog_Alert_Custom
Run Code Online (Sandbox Code Playgroud)
这适用于Alert Dialogs和Dialogs,但出于某种原因它没有主题Progress Dialogs.我不得不从我的基本主题中删除android:alertDialogTheme并将其放在v21/styles.xml中,以便在Pre-L设备上没有不良行为(双背景)的主题进度对话框.