Material-components-android: strokeColor not working for MaterialCardView

Created on 9 Jan 2019  路  8Comments  路  Source: material-components/material-components-android

Hi!
I wanted to add a border to a MaterialCardView from the dependency: com.google.android.material:material:1.0.0, but the strokeColor isn't applied.

Most helpful comment

I had the same problem: the stroke color was always white. I noticed that this behavior was triggered by the app:cardUseCompatPadding="true" property. By removing it, the stroke color should be working as expected. Not sure if it's a bug or if I missunderstood what "compat padding" is.

All 8 comments

Any screenshots or code?

Hi!
Sorry, it is working now, I'm not sure what I missed. My bad. You can close this issue.
Thanks,
Tamas

The theme has to be a material theme. MaterialCardView didn't enforce that in 1.0.0.

I had the same problem: the stroke color was always white. I noticed that this behavior was triggered by the app:cardUseCompatPadding="true" property. By removing it, the stroke color should be working as expected. Not sure if it's a bug or if I missunderstood what "compat padding" is.

Compat padding is always enabled on Android 4. Can you test how it behaves there?

Hi, i have the same issue when I apply a white color as stroke color, the rest colors are great.

stroke color is not working foe me. see below example :
android:id="@+id/profileCardLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/margin_4"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:rippleColor="@android:color/holo_orange_dark"
app:strokeColor="@color/primaryOrange"
app:cardUseCompatPadding="true"
app:strokeWidth="1dp">

let me know if I am doig something wrong.

@grvgoel81 I guess you need to remove
app:cardUseCompatPadding="true"

Was this page helpful?
0 / 5 - 0 ratings