Skip to content

Latest commit

 

History

History
executable file
·
117 lines (84 loc) · 2.91 KB

README_ZH.md

File metadata and controls

executable file
·
117 lines (84 loc) · 2.91 KB

ViewPager-LayoutManager Download build

English | 中文

logo

VPLM 实现了一些常见的动画效果,如果你有什么别的想要的效果欢迎给我提ISSUE以及PR

circle circle_scale carousel gallery rotate scale

自定义属性

customize

各个layoutmanager都有各自的一些属性可以设置 比如:

  • 半径
  • 滚动速度
  • 间隔
  • 排列方向

可以运行下demo看下具体有哪些属性可以设置

循环列表

infinite

自动滚动到中心

在每次拖动或者快速滑动的时候,你可以通过设置 CenterSnapHelper 让目标 view 自动停在屏幕中央

// work exactly same as LinearSnapHelper.
new CenterSnapHelper().attachToRecyclerView(recyclerView);

设置可见个数

layoutmanager.setMaxVisibleItemCount(count);

获取中间item的位置

layoutmanager.getCurrentPosition()

滚动到特定位置

一般情况下,直接使用RecyclerView自带的smoothScrollToPosition就可以了, 但是当无限滚动开启的时候,如果能获取到要滚动到的view建议使用下面的方法。

ScrollHelper.smoothScrollToTargetView(recyclerView, itemViewYouWantScrollTo);

自动轮播

请使用 AutoPlayRecyclerView

<com.leochuan.AutoPlayRecyclerView
    android:id="@+id/recycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:direction="right"
    app:timeInterval="1500"/>

安装

Gradle:

repositories {
  jcenter()
}

dependencies {
  compile 'rouchuan.viewpagerlayoutmanager:viewpagerlayoutmanager:2.x.y'
}

Maven:

<dependency>
  <groupId>rouchuan.viewpagerlayoutmanager</groupId>
  <artifactId>viewpagerlayoutmanager</artifactId>
  <version>2.x.y</version>
  <type>pom</type>
</dependency>

快速开始

使用前请确保每一个view的大小都相同,不然可能会发生不可预料的错误。

你可以通过新建一个Builder来设置各种属性:

new CircleLayoutManager.Builder(context)
                .setAngleInterval(mAngle)
                .setMaxRemoveAngle(mMaxRemoveAngle)
                .setMinRemoveAngle(mMinRemoveAngle)
                .setMoveSpeed(mSpeed)
                .setRadius(mRadius)
                .setReverseLayout(true)
                .build();

或者只是简单的调用一下预设的构造方法:

new CircleLayoutManager(context);

License

Apache-2.0. 详情见 LICENSE