How to display an image that is larger than the phone screen?

I have a question that I have not found a real consistent answer to. That is why I am speaking to you guys.

I am trying to achieve the β€œviewfinder” effect for my application in the following sense:

I have a huge picture that I want to be able to "fly" (scroll horizontally and vertically until I get to the borders). So far, all the popular answers to this (or similar questions) have been to use a scheme that resembles something like this:

<ScrollView...> <RelativeLayout ...> <Imageview ...> </Imageview> </RelativeLayout> </ScrollView> 

This does not work for me, because it reduces the image that I am trying to save in the original BIG size so that I can let the user navigate through it.

I think my question boils down to this: how do I get the Google Maps scrolling feature using Android views and layouts, if at all possible ... If not, do you have a suggestion? Should I focus more on 2D Canvas operations?

Thanks.

+4
source share
2 answers

You can specify a scaleType in the center for ImageView , so as not to scale the image.

 <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="center" android:src="@drawable/myImage" /> 

You can also use HorizontalScrollView to scroll horizontally.

+4
source

Beware of loading large images into RAM - remember that only 20 MB or so is allowed for raster memory (depending on the device).

If you can somehow tear the image into tiles, you can use the 2D scroll class here to display it.

+1
source

Source: https://habr.com/ru/post/1394485/


All Articles