Android uses viewpager to realize the picture can slide left and right, with code download

First of all, show you beautiful photos. Friends interested in renderings can continue to read.

The small demo of viewpager can slide the picture in a circular way left and right. There is an index below. When sliding to the last page, the first page will slide to the right, and the first page will slide to the left to the last page. Above is the effect picture. Using beautiful pictures is my consistent style, ha ha

1. First look at some XML under layout

To use viewpager, you first need to introduce the jar package android-support-v4.jar. Don't forget to add it yourself

Like friends download the code directly. Code download

In the above code, when there are only 3 pictures or 2 pictures, the bug problem of sliding is modified as follows

Removeview is not allowed in destroyitem (view container, object object) method

The above code shows you that Android uses viewpager to realize the effect that pictures can slide left and right. I hope you like it.

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