0

I have the following ImageView in my XML layout:

<ImageView
   android:id="@+id/image_attachement"
   android:layout_width="@dimen/round_button_medium"
   android:layout_height="@dimen/round_button_medium"
   android:layout_marginBottom="12dp"
   android:background="@drawable/rounded_rectangle"
   android:contentDescription="@string/imageattachment"
   android:onClick="@{()-> viewModel.openGalleryOrImageCameraEvent()}"
   android:padding="@dimen/spacing_large"
   android:scaleType="fitCenter"
   app:layout_constraintBottom_toBottomOf="parent"
   app:layout_constraintEnd_toStartOf="@+id/sendButton"
   app:layout_constraintHorizontal_bias="0.5"
   app:layout_constraintStart_toEndOf="@+id/audio_attachement"
   app:srcCompat="@drawable/ic_photo_camera_black_24dp" />

Here is an image how the ImageView looks like:

enter image description here

Now, when the user selects an image from camera or the gallery, I want to show the thumbnail of that selected image inside this imageview. Here is my Glide code to achieve that:

val requestOptions = RequestOptions()
    .placeholder(R.drawable.white_background)
    .error(R.drawable.white_background)

val requestManager =
    Glide
        .with(context.applicationContext).setDefaultRequestOptions(requestOptions)
        .load(uri).apply(RequestOptions.centerCropTransform()).into(bindingGroupContainer.imageAttachement)

The result is this:

enter image description here

As you can see, the image goes over the boundaries of my rounded rectangle drawable. How can I put the image inside the ImageView so that everything fits well ?

ebeninki
  • 909
  • 1
  • 12
  • 34
  • Does this answer your question? [How to make border for circle cropped image in glide](https://stackoverflow.com/questions/34037939/how-to-make-border-for-circle-cropped-image-in-glide) – ADM Mar 17 '20 at 14:54
  • On a Side not Use Glide Transformation . Use the latest answer you can also checkout [Glide transformation](https://bumptech.github.io/glide/doc/transformations.html) for more. – ADM Mar 17 '20 at 14:58

0 Answers0