自定义dialog实现窗口四个直角变为弧形

来源:互联网 发布:a5源码站 编辑:程序博客网 时间:2024/05/16 09:41

原文地址:http://blog.csdn.net/zengchao2013/article/details/50722627


首先,在自定义dialog的布局文件中添加:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/confirm_dialog_bg"
    android:orientation="vertical" >

</LinearLayout>


添加以下confirm_dialog_bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <corners android:radius="10dp" />
<solid android:color="@color/white" />
</shape>


最后把dialog new出来后

FilterDialog dialog = new FilterDialog(this);

dialog.getWindow().setBackgroundDrawableResource(R.color.photo_pick_transparent);


在color中添加全透明属性

<color name="photo_pick_transparent">#00000000</color>


你会惊喜的发现,dialog的四角变得弧形了!


原创粉丝点击