CardView 角在 AlertDialog 中不圆

CardView corners not rounded in an AlertDialog

我正在创建一个 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>

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

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

调用 alertDialog.getWindow().setBackgroundDrawableResource(android.R.color.transpare‌​nt);AlertDialog 的背景设置为透明,它将起作用