Analysis of key points of sliding paging using viewpager in Android App

In the past, if you wanted to do tab paging, you had to use a very difficult tabactivity, and the effect was very poor and the elasticity was very small

I forgot when Google released viewpager, which replaced the previously difficult Gallery components, and finally made a beautiful and easy-to-use layout after importing fragments from honeycom!

Here we use pagertabstrip, and the results are as follows

The feature is that it is easy to use. The effect is that the text of the currently displayed pagination tab will be automatically centered, and then the previous / next tab will be displayed on the left and right respectively. And when you slide the tab, the following pagination will automatically switch. The implementation method is as follows: your_ layout.xml

... first, in your layout file, find the place where you place the viewpager, and insert the pagertabstrip, where Android: layout_ You can specify top or bottom for gravity to see whether you want it above or below the viewpager. Then in the Java code section. MainActivity.java

Basically, open the part of the indicator bar, and then set the background and the color of the indicator bar. That's it! Prohibit the left and right sliding of the viewpager. If you want to prohibit the sliding, you can override the onintercepttouchevent (motionevent arg0) method and ontouchevent (motionevent arg0) method of the viewpager. The return values of these two methods are of boolean type. Just change the return value to false, and the viewpager will not consume the finger sliding event, Instead, it is passed to the upper view for processing, or the event is terminated directly.

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