改变support中AlertDialog的样式
2016-12-16 19:09
344 查看
android最近的support库提供了AlertDialog,可以让我们在低于5.0的系统使用到跟5.0系统一样的Material Design风格的对话框,但是使用了一段时间想到一些办法去改变对话框按钮字体的颜色,都不生效。
最近在网上找到了改变的方法,首先来说一下。
在values/styles.xml中定义一个主题:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="alertDialogTheme">@style/MyAlertDialogStyle</item>
....
</style>
在创建的对话框的时候,这样创建就可以了。
最近在网上找到了改变的方法,首先来说一下。
改变AlertDialog的样式
在values/styles.xml中定义一个主题:<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="alertDialogTheme">@style/MyAlertDialogStyle</item>
....
</style>
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert"> <!-- Used for the buttons --> <item name="colorAccent">#FFC107</item> <!-- Used for the title and text --> <item name="android:textColorPrimary">#FFFFFF</item> <!-- Used for the background --> <item name="android:background">#4CAF50</item> </style>
在创建的对话框的时候,这样创建就可以了。
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle); builder.setTitle("AppCompatDialog"); builder.setMessage("Lorem ipsum dolor..."); builder.setPositiveButton("OK", null); builder.setNegativeButton("Cancel", null); builder.show();
相关文章推荐
- 转载]改变DatePickerDialog/TimePickerDialog的样式
- AlertDialog的样式修改
- AlertDialog自定义样式
- AlertDialog样式
- AlertDialog自定义样式
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- Fragment弹dialog的主题样式——FragmentDialogSupport
- AlertDialog自定义样式
- AlertDialog 自定义样式
- AlertDialog.Builder 样式设置
- 修改系统AlertDialog样式、自定义Dailog-----Activity透明效果
- AlertDialog自定义样式显示圆角背景失败
- 改变Android中默认Dialog的样式
- android dialog和activity 改变出现消失的 动画样式
- bootbox自定义dialog、confirm、alert样式,以及基本设置方法setDefaults中可用参数
- Android AlertDialog框架(能自用改变字体颜色)
- AlertDialog自定义View的用法+如何改变弹出框的大小
- Flex改变Alert、Tooltip组件样式
- MaterialDialog 仿Android 5.0原生的AlertDialog样式的对话框
- 改变Dialog的样式