androidandroid-layoutborderandroid-cardviewmaterialcardview

How to remove MaterialCardView borders


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


Solution

  • 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"
        ../>