您的位置:首页 > 其它

自定义AlertDialog主题

2016-05-11 21:53 423 查看

自定义AlertDialog主题

解决以下几个问题:

andoird5.0后,dialog的按钮上英文字全为大写的现象

使android5.0后button上的字体变为白色

解决在5.0以下版本会出现的窗口重叠现象

指定AlertDialog的主题

<resources>
<style name="MyAppTheme" parent="android:Theme.DeviceDefault">
<item name="android:textAllCaps">false</item>
<item name="android:alertDialogTheme">@style/MyDialogTheme</item>
</style>

<style name="MyDialogTheme" parent="@android:style/Theme.DeviceDefault.Dialog">
<item name="android:buttonBarButtonStyle">
@android:style/DeviceDefault.ButtonBar.AlertDialog
</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
</style>

</resources>


说明:

<item name="android:textAllCaps">false</item>


解决在andoird5.0后,dialog的按钮上英文字全为大写的现象

<item name="android:buttonBarButtonStyle">
@android:style/DeviceDefault.ButtonBar.AlertDialog
</item>


使android5.0后button上的字体变为白色,默认是蓝色

<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>


解决在5.0以下版本会出现的窗口重叠现象

指定App主题

在AndroidManifest.xml文件中,指定app主题。只需要在application标签中指定Android:theme的值即可:

android:theme="@style/MyAppTheme"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: