How do I display a large png file and scroll around it?

十年热恋 提交于 2019-12-25 13:16:21

问题


I have a large Png image file that I would like to display and scroll around it as I can do in a WebView. When I load my activity with the image file into an ImageView the image is displayed in the screen but is too small to read. I guess the Zoom controls will help once the image it is at it's normal size. I have tried using the image in a WebView but I don't want the Url displayed.


回答1:


I've done something similar with a TableLayout. I wrapped it in a ScrollView nested in a HorizontalScrollView and the user is able to scroll around in all directions when my TableLayout takes up more space than what will fit on the screen. I imagine this would work with an ImageView as well. Something like this:

    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </ScrollView>
    </HorizontalScrollView>



回答2:


Create your own Custom Scrollable Image View. I have used this in a game, it works, and you can scroll in x, y directions.




回答3:


I posted one solution for the same question here: Images in ScrollView in android




回答4:


You said you tried a WebView but you don't want the URL displayed? Do you mean that you see an address bar at the top? If so, please see the answer to this question.



来源:https://stackoverflow.com/questions/5031097/how-do-i-display-a-large-png-file-and-scroll-around-it

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