0

I have layout like this

<androidx.cardview.widget.CardView
android:layout_width="120dp"
android:layout_height="192dp"
app:cardCornerRadius="10dp"
app:cardElevation="8dp"
android:layout_margin="8dp">

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/imageView_category"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:src="@drawable/meditations_image_1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/title_category"
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:background="@color/dark_brown_color"
        android:gravity="center"
        android:textColor="@android:color/white"
        android:textSize="12sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        tools:text="Happiness" />
</androidx.constraintlayout.widget.ConstraintLayout>

and in my adapter I set image in imageview with glide

 Glide.with(image.context)
                .load(item.imageUrl)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(image)

and I receive this enter link description here Why glide put top margin white and do not have rounded corners in image? But if I put image from resource, all nice

Zoe
  • 27,060
  • 21
  • 118
  • 148
Vadim Fedchuk
  • 168
  • 10

1 Answers1

0

you have to add below property in your CardView

card_view:cardPreventCornerOverlap="false"

so your CardView is like below

<androidx.cardview.widget.CardView
android:layout_width="120dp"
android:layout_height="192dp"
card_view:cardPreventCornerOverlap="false"
app:cardCornerRadius="10dp"
app:cardElevation="8dp"
android:layout_margin="8dp">

</androidx.cardview.widget.CardView>
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50