I have a vertical LinearLayout where one of the items is an ImageView
loaded using Picasso. I need to rise the image's width to the full device width, and to display the center part of the image cropped by a fixed height (150dp). I currently have the following code:
Picasso.with(getActivity())
.load(imageUrl)
.placeholder(R.drawable.placeholder)
.error(R.drawable.error)
.resize(screenWidth, imageHeight)
.centerInside()
.into(imageView);
Which values should I put into screenWidth
and imageHeight
(=150dp)?
Image resizing with the pointer toolBy clicking and dragging on these handles, the object is resized by moving the edge or corner clicked on to adjust the width and/or height of the selected object. If the Shift key is held down whilst moving the handle, then the proportions of the object will be preserved.
You are looking for:
.fit().centerCrop()
What these mean:
fit
- wait until the ImageView
has been measured and resize the image to exactly match its size.centerCrop
- scale the image honoring the aspect ratio until it fills the size. Crop either the top and bottom or left and right so it matches the size exactly.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