8

I'm using this layout

<android.support.design.card.MaterialCardView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="0"
    app:cardCornerRadius="24dp"
    card_view:cardElevation="0dp"
    card_view:cardMaxElevation="0dp">
  <ImageView
      android:id="@+id/close_button"
      android:layout_width="48dp"
      android:layout_height="48dp"
      android:layout_gravity="top|end"
      android:padding="@dimen/account_menu_close_button_padding"
      android:alpha="0"
      app:srcCompat="@drawable/quantum_gm_ic_close_vd_theme_24"
      />
</android.support.design.card.MaterialCardView>

but I get a cardView with tiny border

enter image description here

How can I remove this border and make the cardview transparent?

I saw this similar post, but it gives no answer

Elad Benda
  • 35,076
  • 87
  • 265
  • 471

2 Answers2

8

Have you used these,

app:strokeColor
app:strokeWidth
hemen
  • 1,460
  • 2
  • 16
  • 35
6

Just use the MaterialCard included in the Material Components library that extends the androidx.cardview.widget.CardView (the old CardView included in support library).

You can change the border using the app:strokeWidth attribute. The default value is 0.

<com.google.android.material.card.MaterialCardView
    app:strokeColor="@color/..."
    app:strokeWidth="xxdp"
    ../>
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • If the default value is 0, how come the stroke appears ? When I set it to 0, I don't see it anymore... – android developer Oct 25 '22 at 14:26
  • @androiddeveloper. I faced this problem! when I migrated from material 2 to material 3. it might be inherit from somewhere else by default . – NimaAzhd Oct 27 '22 at 12:58