I have a lot of doubts about the treatment of the images in android, and I was hoping to see if you could solve them.
At this point I have an image that occupies 320 dp high, and match_parent width, which is around 60% of the screen. This image of the load with Glide, of some images in 1080 that I have personally.
I tried to make centroCrop and fitXY, but always deform the images. The first type I know cuts the image, but the second one fits a size, but it does deform the image high or wide.
Is there any way, to insert it with Glide and see it as it is? What properties have I to touch on ImageView and which of Glide?
<ImageView android:id="@+id/img" android:layout_width="match_parent" android:layout_height="match_parent" android:nestedScrollingEnabled="false" app:layout_collapseMode="parallax" android:scaleType="fitXY" app:layout_scrollFlags="scroll|enterAlways" />
Add an explicit width or height to the ImageView by setting layout_width=500dp in the layout file. Call . override(width, height) during the Glide load and explicitly set a width or height for the image such as: GlideApp.
Option 1: Resizing image size with override(x, y) . centerCrop() is a cropping technique that scales the image so that it fills the requested bounds of the ImageView and then crops the extra. The ImageView will be filled completely, but the entire image might not be displayed.
Image Resizing with override(x, y) Glide automatically limits the size of the image it holds in cache and memory to the ImageView dimensions.
Override
must be accessed via RequestOptions
in the most recent version of Glide 4.x
. You can add RequestOptions
through apply()
Glide.with(context) .load(path) .apply(new RequestOptions().override(600, 200)) .into(imageViewResizeCenterCrop);
in glide 4.x 'override' is in 'apply' :
Glide.with(getBaseContext()) .load(path) .apply(RequestOptions.placeholderOf(R.mipmap.no_wifi) .error(R.mipmap.no_wifi) .override(500,500)) .into(mImageView);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With