CardView角落未在AlertDialog中舍入

时间:2015-05-21 10:46:06

标签: android android-layout rounded-corners android-cardview

我正在创建AlertDialog,该对话框的自定义布局为CardView(该卡是xml布局的根目录):

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/moreInfoCard"
    android:layout_gravity="center"
    app:cardCornerRadius="12dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    //my layout content

</android.support.v7.widget.CardView>

当我显示对话框时,卡片的边角为圆角,但角落的背景则不透明。

enter image description here

我该如何解决这个问题?提前谢谢。

1 个答案:

答案 0 :(得分:12)

致电alertDialog.getWindow().setBackgroundDrawableResource(android.R.color.transpare‌​nt);AlertDialog的背景设置为透明,然后才会有效

相关问题