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

。_饼干妹妹 提交于 2019-12-12 09:43:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!