您的位置:首页 > 移动开发 > Android开发

一个ViewPager的页面切换指示控件

2016-10-26 10:17 260 查看

运行效果:



使用说明:

依赖:
compile 'com.romandanylyk:pageindicatorview:X.X.X'

把xxx替换成版本号,最新版本0.0.4.

定义PageIndicatorView
    <com.rd.PageIndicatorView
        android:id="@+id/pageIndicatorView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        attrs:viewPager="@id/viewPager"/>

设置ViewPager
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPager.setAdapter(adapter);
//instance of android.support.v4.view.PagerAdapter adapter
 
PageIndicatorView pageIndicatorView = (PageIndicatorView) view.findViewById(R.id.pageIndicatorView);
pageIndicatorView.setViewPager(viewPager);

自定义
//set size
setCount(int count)
setDynamicCount(boolean dynamicCount)
 
setRadius(int radiusDp)
setPadding(int paddingDp)
 
//set color
setUnselectedColor(int color)
setSelectedColor(int color)
 
//set animation
setAnimationDuration(long duration)
setAnimationType(AnimationType type)
setInteractiveAnimation(boolean isInteractive)
 
//set selection
setProgress(int selectingPosition, float progress)
setSelection(int position)



下面是PageIndicatorView支持的所有动画效果。
NameSupport versionPreview
AnimationType.NONE0.0.1
AnimationType.COLOR0.0.1
AnimationType.SCALE0.0.1
AnimationType.SLIDE0.0.1
AnimationType.WORM0.0.1


相关代码


ParallaxPagerTransformer


DragTopLayout


freepager


MultiViewPager


MaterialViewPager

下载地址:https://github.com/romandanylyk/PageIndicatorView
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 界面