question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MaterialCardView] stroke not rendering in preview

See original GitHub issue

Description: When applying stroke for the card it doesn’t show at all in the preview, but in the emulator and physical device it shows normally with no issues.

Expected behavior:

Preview

preview

Physical device

device

Source code:

    <com.google.android.material.card.MaterialCardView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="top|center_horizontal"
        android:layout_margin="20dp"
        app:cardCornerRadius="10dp"
        app:cardElevation="10dp"
        app:strokeColor="@color/red"
        app:strokeWidth="5dp">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:padding="10dp"
            android:text="Stroke should be showing"
            android:textColor="@color/textDark"
            android:textSize="@dimen/text_mini" />

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

Android API version: tested on 29 and 30

Material Library version: 1.3.0-alpha03

Device: no problem with the device

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hunterstichcommented, Oct 20, 2020

Perfect. Thanks for the quick response.

I’ve passed this along to the Android Studio team

0reactions
AlaaZarifacommented, Oct 20, 2020

@jgaillard85 Great. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

strokeColor and strokeWidth not working in androidx.cardview ...
Just use the Material Components Library and the MaterialCardView which extends the androidx.cardview.widget.CardView . Something like:
Read more >
MaterialCardView | Android Developers
Without a strokeColor , the card will not render a stroked border, regardless of the strokeWidth value. Cards implement Checkable , a default ......
Read more >
Cards - Material Design
Note: Without an app:strokeColor, the card will not render a stroked border, regardless of the app:strokeWidth value. Checked icon attributes. Element ...
Read more >
Hands-on with Material Components for Android: Cards
A MaterialCardView can be included in your layout like so: ... This defaults to 0dp (and will not be rendered if no strokeColor...
Read more >
Set stroke, fill, drop shadow, and inner shadow for objects
As you modify the options in the color picker, you can preview the changes on the artboard. Note: Adobe XD also supports shorthand...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found