Android Image Viewer, Full Screen Zoom and CenterCrop
How can I get an image that fills the screen but maintains its aspect ratio and fits in the center?
I currently have large images, larger than my phone screen resolution, but I suspect they will be inboxes on higher resolution devices
What combination scaleType
will perform the trick?
source to share
You can just use adjustViewBounds
value to keep the aspect ratio of the image
<ImageView
android:id="@+id/metallicaImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="@drawable/metallica" />
source to share
I ran into this before, the problem is that when the image needs to be scaled (screen width is larger than the image), Android will not scale the image beyond its given size. However, scaling works just fine.
I ended up creating the AspectRatioImageView
one mentioned below works well. Be sure to read the comments about getIntrinsicWidth()
returning 0 and getDrawable()
returning zero and put some security checks in them.
How do I stretch three images across the screen while maintaining the aspect ratio?
source to share