Android MaterialCardView cut corner style

Viewed 763

I used a MaterialCardView

I've given it a Cut Corners style

But the views are far from the corners

IMAGE: Image spacing

It also I used the following code:

app:cardPreventCornerOverlay="true"

But it does not clip the corner

IMAGE: not croped image

Can anyone help me?

<com.google.android.material.card.MaterialCardView
   android:id="@+id/topLayout"
   android:layout_width="0dp"
   android:layout_height="0dp"
   android:clipChildren="true"
   app:cardBackgroundColor="@color/colorBackground"
   app:cardElevation="1.5dp"
   app:layout_constraintBottom_toTopOf="@+id/navigationBar"
   app:layout_constraintEnd_toEndOf="parent"
   app:layout_constraintStart_toStartOf="parent"
   app:layout_constraintTop_toBottomOf="@+id/toolbar"
   app:shapeAppearanceOverlay="@style/CardView.Shape.Cut">

   <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginStart="-21dp"
      android:layout_marginTop="-21dp"
      android:layout_marginEnd="-21dp"
      android:layout_marginBottom="-21dp"
      app:layout_constraintBottom_toBottomOf="@+id/topLayout"
      app:layout_constraintEnd_toEndOf="@+id/topLayout"
      app:layout_constraintStart_toStartOf="@+id/topLayout"
      app:layout_constraintTop_toTopOf="@+id/topLayout">

      <androidx.appcompat.widget.AppCompatImageView
          android:layout_width="match_parent"
          android:layout_height="210dp"
          android:scaleType="centerCrop"
          android:src="@drawable/photo_profile" />

   </RelativeLayout>

IMAGE: from top code

if use of:

app:cardPreventCornerOverlay="true"

IMAGE: cardPreventCornerOverlay

1 Answers
Related