Rollviewpager picture rotation effect open source framework usage details

Rollviewpager is an automatic rotation viewpager that supports infinite loops. When touching, the playback will be suspended until a delay period is reached. It looks like this. The indicator can be a point, a number, a custom, or a different position.

Attach rollviewpager GitHub address: https://github.com/Jude95/RollViewPager

Add dependencies on gradle using Android Studio development:

Use in layout files:

To use the rollviewpager custom attribute, we must add:

Rollpagerview custom properties:

app:rollviewpager_ play_ Delay = "3000" playback interval, unit: Ms. If 0 is filled in, it will not be played. The default is 0 app: rollviewpager_ hint_ Gravity = "center" indicator position, left, center, right. Default center app: rollviewpager_ hint_ Color = "#7c7c7c" indicator background color. Default black app: rollviewpager_ hint_ Alpha = "80" indicator background transparency. 0 is fully transparent and 255 is opaque. Default 0. App: rollviewpager_ hint_ Paddingleft = "16dp" left margin of indicator app: rollviewpager_ hint_ Paddingright = "16dp" indicator right margin app: rollviewpager_ hint_ Paddingtop = "16dp" indicator top margin app: rollviewpager_ hint_ Paddingbottom = "16dp" indicator bottom margin

Usually specify the interval.

Rollviewpager provides a custom indicator class: hintview usage:

Parameter Description: context, current rotation chart indicator picture, default indicator picture mrollviewpager.sethintview (New iconhintview (this, r.drawable.point_focus, r.drawable.point_normal)); mRollViewPager.setHintView(new ColorPointHintView(this,Color.YELLOW,Color.WHITE)); mRollViewPager.setHintView(new TextHintView(this)); mRollViewPager.setHintView(null);// Hide indicator

Set click event:

The following three convenient pageradapters are provided for use.

This viewpager can also use any other pageradapter.

StaticPagerAdapter:

The adapter that stores the page. If the view is added, the getview will not be stored again, reducing the consumption of page creation and memory consumption. Generally, this scheme is better for automatic playback. Otherwise, a large number of views will be constructed. Refer to fragmentpageradapter for concept. Can be used with other viewpagers.

Dynamicpageradapter (the same usage as the above adapter) is a dynamic adapter. When creating view No. 3, view No. 1 will be destroyed (recursive), and getview will be called from time to time. Increase page creation consumption and reduce memory consumption. Refer to fragmentstatepageradapter for concept. Can be used with other viewpagers.

LoopPagerAdapter

Infinite loop adapter. The infinite loop adopts the method of getcount returning a large number of int (there is no disadvantage. In addition, it is estimated that the interval of 1s will not be played in your lifetime). The actual measurement is better than jumping from page n to page 1.

The data adopts the scheme of staticpageradapter. Save the cost of creating view. This adapter can only be used for this rollviewpager;

No other settings are required. It's simple.

Playback control

Mainactivity Code:

XML code:

Attach renderings:

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