Android realizes large picture scrolling display effect
Question:
I have a relatively large picture. For example, the length and width are twice the size of the screen. The function I want to achieve is to first display the picture in the center. Because the picture is too large, it can only display a part. Then, I can drag to realize the smooth scrolling of the picture (I can't see the trace of scrolling and refreshing).
Just like Google maps, if you use the MapView control, you can drag the entire map on the screen. However, due to the large amount of map information, if you drag too fast at one time, the screen will temporarily display some refresh marks (gray grid).
I wanted to use MapView to load existing pictures, but it didn't succeed. Later, I also used the srollview control and the most commonly used ImageView, but it didn't succeed.
solve:
After a lot of data searching, it can be solved by using ImageView in combination with ontouch events.
Key codes:
The ImageView control in the layout file is as follows
The main codes in the activity file are as follows
Original drawing
Effect in simulator
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.