2

I'm using Glide 4.0 to load an image into an ImageView with scaleType="matrix" for pan and zoom functionality. The image does not load centered. If it is tall it loads to the left and if it is wide it loads at the top (see pictured). I've tried the various RequestOptions but none will center the image initially. How can I accomplish this? Thanks!

Current Tall or Wide Image Position

Activity

Uri selectedImage = returnedIntent.getData();
RequestOptions options = new RequestOptions().fitCenter();
Glide.with(MyActivity.this).load(selectedImage).apply(options).into(mImage);

Layout

<ImageView
  android:id="@+id/m_image"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:scaleType="matrix" />

1 Answers1

0

you are overriding the functionality of scaleType attribute by using .apply(options)

only remove it so the request will be Glide.with(MyActivity.this).load(selectedImage).into(mImage);

you may find this link helpful https://github.com/wasabeef/glide-transformations/issues/94

Hazem Ashraf
  • 310
  • 2
  • 8