lsjwzh / RecyclerViewPager

Deprecated
Apache License 2.0
3.53k stars 667 forks source link

selected pager not overlap right pager. #88

Open afiqiqmal opened 8 years ago

afiqiqmal commented 8 years ago

can someone help me with this? I trying to do selected page is overlap left and right pager but failed.. Only left page is overlap..right is not. how to bring the selected page to the front?

dadu1 commented 8 years ago

Hi @afiqiqmal

You can apply this changes to achieve your goal.

for (int j = 0; j < childCount; j++) {
                    View v = recyclerView.getChildAt(j);
                    //往左 从 padding 到 -(v.getWidth()-padding) 的过程中,由大到小
                    float rate = 0;
                    if (v.getLeft() <= padding) {
                        if (v.getLeft() >= padding - v.getWidth()) {
                            rate = (padding - v.getLeft()) * 1f / v.getWidth();
                        } else {
                            rate = 1;
                        }
                        v.setScaleX(1 + rate * 0.1f);
                        v.setScaleY(1 - rate * 0.1f);
                    } else {
                        //往右 从 padding 到 recyclerView.getWidth()-padding 的过程中,由大到小
                        if (v.getLeft() <= recyclerView.getWidth() - padding) {
                            rate = (recyclerView.getWidth() - padding - v.getLeft()) * 1f / v.getWidth();
                        }
                        v.setScaleX(1.0f + rate * 0.1f);
                        v.setScaleY(0.9f + rate * 0.1f);
                    }
                }
            }
in onscrolled method of recycler view's scroll listener.
Hope this may help you
nothinglhw commented 7 years ago

@afiqiqmal I have the same problem.