自定义AlertDialog主题

自定义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"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值