How do I make a child ImageView clip to the bounds of its parent? When I add an ImageView as a child to a parent view with rounded corners, the child ImageView does not conform to the rounded corners.
I have tried:
android:cropToPadding
android:clipChildren
android:clipToPadding
android:adjustViewBounds
I have set these to true and false on the image view and the parent view, and all possible combinations.
I have a custom view: custom_view.xml for rounded corners
<shape android:shape="rectangle">
<corners android:backgroundTint="@color/backgroundColor" android:radius="10dp" />
<solid android:color="@color/backgroundBlue" />
</shape>
I have a fragment, fragment_card.xml that implements the custom view.
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="105dp"
android:layout_margin="10dp"
android:background="@drawable/custom_view" <-- setting the custom_view
app:cardBackgroundColor="@color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/cardIconView"
android:layout_width="105dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/line_separator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
and it continues...
The child ImageView does not clip to the bounds of the parent view with the custom background. Notice the left corners are not rounded
CardListAdapter:
override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
holder.cardIconView.setImageDrawable(theimage)
}

