Method for realizing large picture rolling display by Android programming

This paper describes the method of large picture scrolling display by Android programming. Share with you for your reference, as follows:

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

The results are as follows:

Original drawing:

Effect in simulator:

More readers interested in Android related content can view the special topics of this site: summary of Android graphics and image processing skills, introduction and advanced tutorial of Android development, summary of Android debugging skills and solutions to common problems, summary of Android multimedia operation skills (audio, video, recording, etc.), summary of Android basic component usage Summary of Android view skills, summary of Android layout skills and summary of Android control usage

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>