siralam / LoopingViewPager

A ViewPager and PagerAdapter combination that support auto scroll, infinite loop and page indicators.
532 stars 64 forks source link

When wrap_content is true be sure to account for padding in LoopingVi… #11

Closed dfbarone closed 5 years ago

dfbarone commented 6 years ago

…ewPager::onMeasure.

onMeasure seems to be broken for me when adding left and right padding to 'peek' at left and right ViewPager items. Also when items scale to a particular ratio based on width.

siralam commented 5 years ago

This does look safe to merge; but I don't see how is it possible to peek left and right item (I don't even think it is possible using ViewPager), may I know how do one user set to peek after this has been merged?

dfbarone commented 5 years ago

I am able to show a preview to the left and right items by setting clipToPadding="false" and adding left/right padding. I have included a screen cap.

<com.asksira.loopingviewpager.LoopingViewPager
    android:id="@+id/viewpager"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:isInfinite="true"
    app:autoScroll="false"
    **android:clipToPadding="false"**
    **android:paddingLeft="25dp"**
    **android:paddingRight="25dp"**
    app:scrollInterval="3000"
    app:wrap_content="true"/>

screenshot_1543289790

siralam commented 5 years ago

OMG... You made my day!!

It works, but you can observe that user will be able to see the sudden appear of looped page because he/she can now peek the next page lol

I will merge this PR though. Thanks!

dfbarone commented 5 years ago

Thank you. Also, stackoverflow.com has some good information about customizing viewpagers. This is how I learned about the clipToPadding trick.

https://stackoverflow.com/questions/13914609/viewpager-with-previous-and-next-page-boundaries https://stackoverflow.com/questions/10098040/android-viewpager-show-preview-of-page-on-left-and-right