Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CardView corners not rounded in an AlertDialog

I'm creating an AlertDialog and the custom layout for that dialog is a CardView (the card is the root of the xml layout):

<?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>

When I show the dialog the card has its corners rounded, but the background of the corners it's not transparent.

enter image description here

How can I solve this issue? Thank you in advance.

like image 894
matteopuc Avatar asked May 21 '15 10:05

matteopuc


1 Answers

call alertDialog.getWindow().setBackgroundDrawableResource(android.R.color.transpare‌​nt); to set the AlertDialog's background to transparent and it will work

like image 189
Blackbelt Avatar answered Sep 20 '22 14:09

Blackbelt