dobriy denyok
dobriy denyok

Reputation: 47

Card view doesn't make corner radius

I have dialog fragment and i set my custom view to it. I want to make it with round corners and im using CardView for it, but the shape of dialog is still rectangle. Here is my view:

 <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="16dp"
    app:cardCornerRadius="40dp">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/card_cl"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="36dp">

            <androidx.appcompat.widget.AppCompatTextView
                android:id="@+id/id_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:textSize="36sp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                android:text="12" />

        </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>

the result : enter image description here

Upvotes: 0

Views: 962

Answers (3)

osaifunky chan
osaifunky chan

Reputation: 1

add below code to your CardView;

app:cardBackgroundColor="@android:color/transparent" 

Upvotes: 0

Mohammad Hanif Shaikh
Mohammad Hanif Shaikh

Reputation: 1501

This is Bcoz The Card color is similar to the background color. You just need to set elevation.

Upvotes: 0

Fahim Fahad Leo
Fahim Fahad Leo

Reputation: 56

Try putting your cardview in a linerlayout or a relative layout if it doesn't work try adding some padding to linerlayout or relativelayout.

Upvotes: 0

Related Questions