首先,在自定义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的四角变得弧形了!