Issue:
I'm loading an image with glide and blur into a ImageButton inside a Relative layout inside a CardView. I've tried all the scale types but I can't make it work. The Relative layout is a must because I have other views inside that need to stack on the blurred image in some conditions. As you can see from the image below, there is a white space on the right side of the card view.
Question:
How to make the image fill the entire cardview while preserving the relative layout?
XML:
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="3dp"
card_view:cardMaxElevation="0dp"
card_view:contentPadding="0dp">
<RelativeLayout
android:id="@+id/photoPlaceRootView"
android:layout_width="174.75dp"
android:layout_height="246dp">
<ImageButton
android:id="@+id/photoPlace"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="0dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginLeft="127dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="0dp"
android:clickable="true"
card_view:fabCustomSize="27dp"
card_view:fabSize="mini"
card_view:maxImageSize="17dp"
card_view:srcCompat="@drawable/icon_eye" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="127dp"
android:layout_marginEnd="0dp"
android:layout_marginBottom="0dp"
android:clickable="true"
card_view:backgroundTint="@color/main_pink_color"
card_view:fabCustomSize="27dp"
card_view:fabSize="mini"
card_view:maxImageSize="17dp"
card_view:srcCompat="@drawable/icon_heart" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
Glide:
Glide.with(activityContext).load(uri).transform(new BlurTransformation(100)).into(holder.photoPlace);
Please let me know if I should add anything else.
<RelativeLayout
android:id="@+id/photoPlaceRootView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/photoPlace"
android:layout_width="wrap_content"
android:layout_height="246dp"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="0dp" />