Using photoview in Android initially displays the full image
I'm developing an Android application. In my application, I need the zoom image function like Facebook. Therefore, I use this library- https://github.com/chrisbanes/PhotoView. But the first time I load an image, I can't display the full image
This is how I set photoviewattacher to ImageView
photoViewAttacher = new PhotoViewAttacher(imageView);
photoViewAttacher.setZoomable(true);
photoViewAttacher.update();
This is the XML layout of ImageView
<ImageView
android:id="@+id/item_details_image"
android:scaleType="fitCenter"
android:layout_width="match_parent"
android:layout_height="match_parent" />
What I want to do is that if the image is larger than the screen size, I want the image display to fit the screen. No matter how large. But the image can be smaller than the screen size. I just want to display the complete image at the beginning. But the above code gives me this result
As you can see in the screenshot, it can't display the whole image. It only displays part of the image. If you want to view other areas of the image, I want to scroll or slide because the image doesn't fit on the screen at first. Therefore, I try to change the XML to initially display the whole image area. This is the XML I changed to
<ImageView
android:id="@+id/item_details_image"
android:scaleType="centerInside"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
As you can see, I will height from match_ Change parent to wrap_ Content. The same is true for the scale type. When I change to this name, it will initially display the full image like this
It shows the full image, but it's small. It's all right for me. That's what I want. The problem is the zoom function. When I zoom in, the image can't be greater than the image height. See the screenshot below
As you can see above, when I zoom in, it will not display the full image. The height of ImageView has not changed
resolvent:
<ImageView
android:id="@+id/item_details_image"
android:scaleType="fitCenter"
android:layout_width="match_parent"
android:layout_height="match_parent" />
You need match_ Parent height or width