android - CardView 角在 AlertDialog 中不圆

标签 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

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

最佳答案

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

关于android - CardView 角在 AlertDialog 中不圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30371504/

相关文章:

ios - 具有深色效果的圆形 UIButton

java - 膨胀 Facebook 登录按钮时出错。

java - 更改 Android Studio 中的默认 LAUNCHER Activity

Android:点击 float 操作菜单不起作用

android - 滑动删除列表项

iOS 如何删除细边框线然后使用 layer.cornerRadius

java - Android 自定义日历的网格布局

Android 调试应用程序在跳出方法/函数时崩溃,在 Release模式下运行正常

android - 如何调整启动器中矢量图标的大小

java - 当父对象具有背景图像时,圆角边框