Dialog.Alert黑色背景

<style name="AlertDialog" parent="Base.Theme.AppCompat.Light.Dialog.Alert">
        <!-- 这里设置背景为透明,为了隐藏边框 -->
        <item name="android:windowBackground">@color/text_color_white</item>
        <item name="android:windowNoTitle">true</item>
        <!-- 这里是修改顶部标题背景颜色,具体颜色自己定,可以是图片 -->
        <item name="android:topDark">@color/text_color_white</item>
        <!-- 这里是修改内容区域背景颜色 -->
        <item name="android:centerDark">@color/text_color_white</item>
        <item name="android:windowAnimationStyle">@android:color/transparent</item>
    </style>
 AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.AlertDialog);
        builder.setTitle("选择性别");
        String[] items = {"男", "女"};
        builder.setItems(items, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                sexChoose.chooseSex(which);

            }
        });
        builder.show();

本来代码是这样的,结果效果是这样的。

查了又查,改了又改,没办法。最后想把自己添加的效果全去掉,变成了这样。

    <style name="AlertDialog" parent="Base.Theme.AppCompat.Light.Dialog.Alert">
       
    </style>

然后就恢复正常了

最后经过排查 是这一项的原因,添上就出现黑背景,去掉就正常了。

 <item name="android:windowBackground">@color/text_color_white</item>
我在另外一个项目里面这样用是没有问题的,但是在这个项目出了问题,比较两个项目activity使用的主题后,没有发现有什么不同

猜测可能是项目里面用的jar或者其他什么原因,猜不透。。。

如果不懂,就从最开始一点来。可能效果会更好。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值