Imageswitcher of Android UI control to realize image switching effect

This example shares the specific code of geswitch to realize the image switching effect for your reference. The specific contents are as follows

As can be seen from the name, imageswitcher is a picture switching control, which can display specific pictures one by one in a series of pictures. Using this control, the functions of the previous and next pictures in the picture browser can be realized. The usage method is also relatively simple, but it should be noted that when using the imageswitcher, it needs a viewfactory to distinguish the container displaying the picture from its parent window.

See the example directly for specific usage. As usual, go to the effect drawing first

See the effect of the next one:

I won't talk more about the layout file. Just look at the code of mainactivity:

Note in the above code:

1. This class implements two interfaces, so it is necessary to implement the methods in the two interfaces in the class. The advantage of this writing is that it is easy to reuse. In subsequent codes, where the two interfaces need to be used, you can directly use the this keyword.

2. Images, as an integer array static constant, stores the IDs of all pictures, which needs to be copied to the drawable directory under the res directory.

3. The setfactory () method tells the system how the imageswitcher wants to display the content, while setimagesource () tells the system where the images to be displayed are obtained.

4. The makeview () method is defined by the viewfactory interface. This method returns a view, and the imageswitcher will display the content according to the layout of the view.

Well, a simple picture browser is finished!

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.

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
分享
二维码
< <上一篇
下一篇>>