kHRYSTAL / CircleRecyclerView

the library is a loop RecyclerView(expression), can show some effects when display
714 stars 100 forks source link

Cardview not set in center #7

Closed vishaljadav24 closed 7 years ago

vishaljadav24 commented 7 years ago

I have used this. Its demo works fine. When i add card view as items in CircleRecyclerView, its work fine without this line circleRecyclerView.setNeedCenterForce(true);

But i want center card view item event in my project. So i add circleRecyclerView.setNeedCenterForce(true); then its shows error java.lang.NullPointerException: Attempt to invoke virtual method 'float android.view.View.getX()' on a null object reference

I do lots of debug on this. then I find getChildCount() in CircleRecyclerView return null. How to resolve this?

kHRYSTAL commented 7 years ago

hi @vishaljadav24 , pls show your code and I thought maybe the item width(when horizontal) or height(when vertical) is too large that make the exception you can try like:

YourLinearLayoutManager mLayoutManager = new YourLayoutManager(context, LinearLayoutManager.YourOrientation) {
            @Override
            protected int getExtraLayoutSpace(State state) {
                return youWantPreloadedHeightorWidth;
            }
        };
vishaljadav24 commented 7 years ago

I want to display only one card at a time. It is working perfectly for multiple items. How to achieve for one item centered.

vishaljadav24 commented 7 years ago

I am getting same error if adding this : LinearLayoutManager mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) { @Override protected int getExtraLayoutSpace(RecyclerView.State state) { return 30; } };

kHRYSTAL commented 7 years ago

hi @vishaljadav24 you can compile 'com.android.support:recyclerview-v7:23.4.0', use LinearSnapHelper or RecyclerViewPager instead this library if you needn't item transformer when scroll

and getExtraLayoutSpace method need return at least one card height if you want to display only one at a time