android中AlertDialog设置圆角

参考网址:https://blog.csdn.net/qq_33224517/article/details/53421307

说明:在AlertDialog自定义布局的时候,想要一个圆角效果,但是给xml设置圆角后,AlertDialog并不是显示的圆角,只有自定义的布局是圆角样式,AlertDialog会显示出一个白色四方的背景

AlertDialog alertDialog = new AlertDialog.Builder(this).create();
Window window = alertDialog.getWindow(); 
//这一句消除白块 
window.setBackgroundDrawable(new BitmapDrawable());
//自定义的xml
window.setContentView(R.layout.mydialog);
alertDialog.show();
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/mywhite" /><!-- 背景色 -->
    <corners android:topLeftRadius="15dp"
        android:topRightRadius="15dp"
        android:bottomRightRadius="15dp"
        android:bottomLeftRadius="15dp"/><!-- 四个圆角的圆角大小 -->
    <stroke android:width="1dp" android:color="@color/mywhite" /><!-- 边框色 -->
</shape>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值