Border not appearing around MaterialCardView

761 views Asked by At

I'm trying to add a border around my MaterialCardView control but for some reason this is not working. I've already added the relevant dependency but it still doesn't seem to have any effect.

Dependency added

dependencies {
    ...
    implementation 'com.google.android.material:material:1.0.0'
    ...
}

XML

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="10dp"
    app:cardUseCompatPadding="true"
    app:cardBackgroundColor="@android:color/transparent"
    app:cardElevation="0dp"
    app:strokeColor="@android:color/black"
    app:strokeWidth="2dp">
[...]

</com.google.android.material.card.MaterialCardView>

Current result

enter image description here

1

There are 1 answers

4
Wahdat Jan On BEST ANSWER
 <com.google.android.material.card.MaterialCardView
    android:id="@+id/item_img_card"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_marginBottom="20dp"
     android:layout_marginTop="10dp"
    android:theme="@style/Theme.MaterialComponents.Light"
    app:cardCornerRadius="10dp"
  
    >