问题
I have a question that I didn't find a real consistent answer for. That is why I am reaching out to you guys.
I've been trying to achieve a 'viewfinder' effect for my application in the following sense:
I have a huge picture that I want to be able to "fly" over (scroll horizontally & vertically until I reach the boundaries). So far, all the popular answers to this (or similar questions) is to use a schema that resembles something like this:
<ScrollView...>
<RelativeLayout ...>
<Imageview ...>
</Imageview>
</RelativeLayout>
</ScrollView>
This does not work for me, because it scales down the picture that I'm trying to keep at the original BIG size so that I can let the user navigate over it.
I guess my question boils down to this: how to get the Google Maps scroll feature using Android Views and Layouts if at all possible... If not, do you have a suggestion? Should I head more towards 2D Canvas operations ?
Thank you.
回答1:
You can specify the scaleType to center for ImageView to not to scale the image.
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/myImage" />
Also you can use HorizontalScrollView to scroll horizontally.
回答2:
Beware of trying to load large images entirely into RAM—remember you’re only allowed 20MB or so (depending on the device) for bitmap memory.
If you can somehow break the image into tiles, you could use the 2D scrolling class here to display it.
来源:https://stackoverflow.com/questions/9119889/how-to-display-an-image-that-is-bigger-than-the-phone-screen-dimensions