Open domoemmanuel99 opened 7 years ago
You cannot do this with setImageListener because it sets imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); by default.
You could use setViewListener instead, for example:
carouselView.setViewListener(new ViewListener() {
@Override
public View setViewForPosition(int position) {
ImageView imageView = new ImageView(getActivity());
imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Picasso.with(getActivity())
.load("http://url.to/image.jpg")
.fit()
.centerInside()
.into(imageView);
return imageView;
}
});
Actually my answer was a bit over-engineered. Should be enough just to set scaleType for imageView in ImageListener:
carouselView.setImageListener((position, imageView) -> {
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
...
Actually my answer was a bit over-engineered. Should be enough just to set scaleType for imageView in ImageListener:
carouselView.setImageListener((position, imageView) -> { imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); ...
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
this is also an option
I have tried both FIT_CENTER and FIT_XY and it's still not working. Any idea?
how can i show all the image without cut any part of image?, i want to download the images from internet with glide, and place it inside the carousel, but when i do it, the image gets cropped on the bottom or on sides(thats beacuse Carouselview has a fixed height and widht variates with screen size), any way to only scale the carouselview height to fit image?(if i set height on wrapcontent the view disapears)how can i acomplish that?