'Card View Custom Background

Here is Background drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#FFFFFF" />
    <corners android:radius="6dp" />
    <stroke
        android:width="1dp"
        android:color="#8C0B0B" />
</shape>

Here is XML Card view where Background Drawer btn_typing_background

    <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="24dp"
                    android:layout_marginTop="25dp"
                    android:layout_marginRight="24dp"
                    android:layout_marginBottom="24dp"
                    android:background="@drawable/btn_typing_background"
                    android:textColor="#969696">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="Add your Phrase"
                        android:textSize="14sp" />

                </androidx.cardview.widget.CardView>

Can Anyone Help with me this, Thank you in advance



Solution 1:[1]

Card view does not support android:background, instead you can use MartialCardView for your usage like this:

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="#FFFFFF"
app:cardCornerRadius="6dp"
app:strokeWidth="1dp"
app:strokeColor="#8C0B0B">

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pejman Azad