Fixed
Status Update
Comments
je...@google.com <je...@google.com> #2
I have a fix ready for this. If you agree that this should be changed, I'll send you a CL
sh...@google.com <sh...@google.com> #3
Yeah, this sounds right to me. Padding effects layout, and the positioning of a item in the center is layout. ClipToPadding just affects how things are drawn. Do you agree?
je...@google.com <je...@google.com> #4
Yes, I do. I'll send a CL with a fix
je...@google.com <je...@google.com>
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 6faf0d9fbabf6b59465ed135b4b44100bb2b3806
Author: Jelle Fresen <jellefresen@google.com>
Date: Wed Aug 14 16:33:05 2019
Always snap to center between padding
Even when clipToPadding is false, the center of RecyclerView is still
the middle of the rectangle described on the inside of the padding, not
the middle of the rectangle described on the outside of the padding.
Bug: 139452422
Bug: 139012032
Test: ./gradlew recyclerview:recyclerview:cC \
-Pandroid.testInstrumentationRunnerArguments.class=\
androidx.recyclerview.widget.PagerSnapHelperTest
Change-Id: I8869f13fdd6a45b49ee3b288ff83e224faffa3c9
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/PagerSnapHelper.java
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PaddingMarginDecorationTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/swipe/PageSwiperEspresso.java
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/swipe/PageSwiperManual.java
https://android-review.googlesource.com/1103182
https://goto.google.com/android-sha1/6faf0d9fbabf6b59465ed135b4b44100bb2b3806
Branch: androidx-master-dev
commit 6faf0d9fbabf6b59465ed135b4b44100bb2b3806
Author: Jelle Fresen <jellefresen@google.com>
Date: Wed Aug 14 16:33:05 2019
Always snap to center between padding
Even when clipToPadding is false, the center of RecyclerView is still
the middle of the rectangle described on the inside of the padding, not
the middle of the rectangle described on the outside of the padding.
Bug: 139452422
Bug: 139012032
Test: ./gradlew recyclerview:recyclerview:cC \
-Pandroid.testInstrumentationRunnerArguments.class=\
androidx.recyclerview.widget.PagerSnapHelperTest
Change-Id: I8869f13fdd6a45b49ee3b288ff83e224faffa3c9
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/PagerSnapHelper.java
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PaddingMarginDecorationTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/swipe/PageSwiperEspresso.java
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/swipe/PageSwiperManual.java
je...@google.com <je...@google.com> #6
Reopened because the issue also exists in LinearSnapHelper
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 1192e296b529ca8e7ed3e282ad52c7677a9bb827
Author: Jelle Fresen <jellefresen@google.com>
Date: Thu Aug 22 11:53:02 2019
Always snap to center between padding
Even when clipToPadding is false, the center of RecyclerView is still
the middle of the rectangle described on the inside of the padding, not
the middle of the rectangle described on the outside of the padding.
Bug: 139452422
Test: ./gradlew recyclerview:recyclerview:cC \
-Pandroid.testInstrumentationRunnerArguments.class=\
androidx.recyclerview.widget.StaggeredGridLayoutManagerSnappingTest
and GridLayoutManagerSnappingTest
and LinearLayoutManagerSnappingTest
Change-Id: Ib4da578d4058b4d0c1ed5425b563de6ee292bd2c
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/LinearSnapHelper.java
https://android-review.googlesource.com/1106715
https://goto.google.com/android-sha1/1192e296b529ca8e7ed3e282ad52c7677a9bb827
Branch: androidx-master-dev
commit 1192e296b529ca8e7ed3e282ad52c7677a9bb827
Author: Jelle Fresen <jellefresen@google.com>
Date: Thu Aug 22 11:53:02 2019
Always snap to center between padding
Even when clipToPadding is false, the center of RecyclerView is still
the middle of the rectangle described on the inside of the padding, not
the middle of the rectangle described on the outside of the padding.
Bug: 139452422
Test: ./gradlew recyclerview:recyclerview:cC \
-Pandroid.testInstrumentationRunnerArguments.class=\
androidx.recyclerview.widget.StaggeredGridLayoutManagerSnappingTest
and GridLayoutManagerSnappingTest
and LinearLayoutManagerSnappingTest
Change-Id: Ib4da578d4058b4d0c1ed5425b563de6ee292bd2c
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/LinearSnapHelper.java
Description
The reasoning is that the padding defines the content rectangle, and whether or not children's pixels are clipped to that rectangle or not doesn't change the semantics of that rectangle.
Consider for example a horizontal ViewPager2 that has unequal padding on the left and the right. When it is in idle state, a page exactly fills the rectangle described by the inner edge of the padding, so the page looks to be off-center by design. When snapping kicks in (e.g., because of a swipe), the page to which it is snapping should end up in that same "off-center" position, exactly matching the rectangle described by the inner edge of the padding, regardless of the value of clipToPadding.