Code Monkey home page Code Monkey logo

viewpagerlayoutmanager's Introduction

ViewPager-LayoutManager Download build

English | 中文

logo

VPLM is a ViewPager like LayoutManager which implements some common animations. If you need some other effects feel free to raise an issue or PR.

circle circle_scale carousel gallery rotate scale

Customzie

customize

Each layoutmanager has bunch of different properties to customize.

Such as:

  • radius
  • scroll speed
  • space
  • orientation

Run the demo to see more details.

Infinite Scroll

infinite

Auto Center

You can make the target view stop right at center every time you swipe or drag by:

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

Set Max Visible Item Count

layoutmanager.setMaxVisibleItemCount(count);

Get Position Of Center Item

layoutmanager.getCurrentPosition()

Smooth Scroll To Position

Normally you can just use RecyclerView's SmoothScrollToPosition method, but when infinite scroll enabled, using method below to avoid some unexpected errors.

ScrollHelper.smoothScrollToTargetView(recyclerView, itemViewYouWantScrollTo);

Auto Play

You can make it auto play by using AutoPlayRecyclerView

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

Download

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>

Quick Start

Make sure that each item has the same size, or something unpredictable may happen.

You can warm up your layoutmanager by Builder.

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

Or just simply call the construct.

new CircleLayoutManager(context);

License

Apache-2.0. See LICENSE file for detail

viewpagerlayoutmanager's People

Contributors

leochuan avatar qinxiandiqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

viewpagerlayoutmanager's Issues

有个小问题

是否有点击左右两边的图片时,图片自动滑动到中间的方法?如果没有可否添加

有个问题

我看你已经弄了 自动滚动的,为什么没把 start stop 方法暴露出来

而且自动轮播的东西 bug 最多了,现在你加的这个,滚动到最后一条数据,下一个数据的滚动就会出现 bug

How to prevent quickly scroll to last item?

If you scroll default recyclerView, then it scrolling with gradual deceleration of speed.
But if I scroll recyclerView with this settings:

mRecyclerView.setLayoutManager(new ScaleLayoutManager(getActivity(),0));
(new LinearSnapHelper()).attachToRecyclerView(mRecyclerView);

then it scrolling with constant speed till to last item. How to prevent it?

Items Cannot be Navigated via Pointer

In devices like Android TV and Android set-top boxes, there is often a remote-controller pointer that is used to navigate activities and lists. In a model I am using (MXQ-4K), the items of list created using ViewPagerLayoutManager cannot be selected or navigated. Other items like buttons and floating action buttons are selectable. Is there a method available in the library to support such navigation?

You can check out the app in action here:
https://youtu.be/glppT8PTmYE

java.lang.IndexOutOfBoundsException: Invalid item position -2(-2). Item count:20

快速滑动必现这个闪退
java.lang.IndexOutOfBoundsException: Invalid item position -2(-2). Item count:20
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5466)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
at rouchuan.customlayoutmanager.ViewPagerLayoutManager.layoutItems(ViewPagerLayoutManager.java:299)
at rouchuan.customlayoutmanager.ViewPagerLayoutManager.scrollHorizontallyBy(ViewPagerLayoutManager.java:262)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4722)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:898)
at android.view.Choreographer.doCallbacks(Choreographer.java:700)
at android.view.Choreographer.doFrame(Choreographer.java:632)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:884)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:238)
at android.app.ActivityThread.main(ActivityThread.java:6016)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:937)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:798)

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.support.v7.widget.OrientationHelper.getMode()' on a null object reference

   java.lang.NullPointerException: Attempt to invoke virtual method 'int android.support.v7.widget.OrientationHelper.getMode()' on a null object reference
                                                                    at android.support.v7.widget.LinearLayoutManager.resolveIsInfinite(LinearLayoutManager.java:1197)
                                                                    at android.support.v7.widget.LinearLayoutManager.updateLayoutState(LinearLayoutManager.java:1162)
                                                                    at android.support.v7.widget.LinearLayoutManager.collectAdjacentPrefetchPositions(LinearLayoutManager.java:1311)
                                                                    at android.support.v7.widget.GapWorker$LayoutPrefetchRegistryImpl.collectPrefetchPositionsFromView(GapWorker.java:94)
                                                                    at android.support.v7.widget.GapWorker.buildTaskList(GapWorker.java:219)
                                                                    at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:364)
                                                                    at android.support.v7.widget.GapWorker.run(GapWorker.java:396)
                                                                    at android.os.Handler.handleCallback(Handler.java:739)
                                                                    at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                    at android.os.Looper.loop(Looper.java:158)
                                                                    at android.app.ActivityThread.main(ActivityThread.java:7224)
                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Why the error may happen?

item点击失效的问题分析

centerSnapHelper关联recyclerview,用carouselLayoutManager.setMoveSpeed((float) 0.25)设置recyclerview的滑动速度后,自动归位会卡顿一下,并且有时item的点击无作用,使用默认的滑动速度不会有上述问题。请帮忙看下!非常感谢!!

你昨天提交之后,程序会异常崩溃

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.support.v7.widget.OrientationHelper.getMode()' on a null object reference
还未分析原因,仅反馈

无限循环

大神,请问实现无限循环有什么思路吗,我们这边有这个需求~ ~

自动轮播不能在Activity OnPause的时候取消轮播

自动轮播不能在Activity OnPause的时候取消轮播,在onResume的时候恢复轮播。。 这样子的话,界面隐藏了,还会一直发现轮播,对内存消耗有影响。

看了源码,好像在AutoPlaySnapHelper有写,但是AutoPlayRecyclerView里面私有了,木有提供出来。

画廊效果

我想实现的画廊效果跟你的有点差别,能不能帮我看看怎么改?方便给下QQ或者WX吗?

Can VPLM Arrange the Items Evenly on the Screen?

Can VPLM automatically arrange the lists items on screen so that they look asymmetrical and not biased. To put it simply, for example, I have three items, then VPLM should scroll to item 1 (second item) and not item 0 (1st item). If I have only one item, then the item should be centered by default, and so on.

I want this:

! [Desired ]
(https://ibb.co/n5AqsG)

But, I see this:

! [Bad]
(https://ibb.co/hXVemb)

RecyclerView does not accept custom animations

Hey
I was trying to apply custom animations to the items of the list using ConstraintLayout animations (an example here). It had no effect. I also tried another library (Bungee). Again didn't work. It seems that VPLM disables all animations. What's your comment on this? Is it impossible to add custom animations to my activity and views when using VPLM?

How to prevent auto duplication of list items in infinite scroll mode

When I set my list to infinite scroll mode using mLayoutManager.setInfinite(true);, the library seems to auto duplicate items to fill the screen if there are only a few items (like two or three) in the list. How can I prevent this from happening. What should I do if I want to see only the items I have set in the list even if there is only 1 or 2 items, while still being able to scroll them infinitely?

List item gets lost in infinite scroll

Hi
I am using CarouselLayoutManager to create a carousel list of items. In a small list with a few items, when set to infinite scroll, after the first round, one of the items gets hidden! What does cause this?

ElevateScaleLayoutManager elevation issue!?

hi, im using ElevateScaleLayoutManager, and it works perfectly fine on android 5+, but on below that i have a problem with elevation (i think), and by that i mean the views on right are always drawn over the views on their left. is there any fix for it?

CarouselLayoutManager constructor error after upgrading to 2.0.1

I just upgraded to 2.0.1 and now in all CarouselLayoutManager constructors I get the following error when trying to run the app:

    protected CarouselLayoutManager createLayoutManager() {
        return new CarouselLayoutManager(Util.Dp2px(this, 100));
    }
Error:(80, 52) error: incompatible types: int cannot be converted to Builder

Has the constructor signature changed in the new version?

D-Pad jumps over the items when navigating with remote controller D-Pad

I noticed that when the system language is set to the Persian (RTL) locale, navigating the items with D-Pad (on remote controller) is wrong. For example you press right on the remote and the list jumps to a random item (not the next). It seems this is only true for android TV (remote controller D-Pad). Testing with keyboard on an emulator device with the Persian locale does not seem to have the problem. Can you please the issue? Is the library dependent on LTR locales to work?

The lists seem to need two swipes to scroll on phone

Hi
The list navigation works perfect with D-Pad on Android TV (MXQ-4K), however, it seems that scrolling the list now requires two swipes and selecting an item needs two taps! I confirm this for a real phone and an emulated device. Can this be an issue with VPLM?

item 宽度问题

用 ScaleLayoutManager 的话,item 不能设置 match_parent,必须要设置固定的宽度
这样会带来适配的问题
能不能改成 margin 或者 padding,就不用设置固定的宽度

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.