Home > Enterprise >  Card view doesn't make corner radius
Card view doesn't make corner radius

Time:11-30

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

CodePudding user response:

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

CodePudding user response:

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

  • Related