Status Update
Comments
[Deleted User] <[Deleted User]> #2
I attach a project to reproduce the issue.
There are 2 buttons: one add a named fragment transaction (which you can remove with back) and the other navigate to another fragment using nav graph.
There are 2 buttons: one add a named fragment transaction (which you can remove with back) and the other navigate to another fragment using nav graph.
jg...@google.com <jg...@google.com>
jg...@google.com <jg...@google.com> #3
You should be using childFragmentManager, not requireFragmentManager(). As of Alpha 04 and https://issuetracker.google.com/issues/111345778 , back button presses are automatically passed to the child FragmentManager of the active Fragment, allowing you to do whatever FragmentTransactions you want in that child FragmentManager (using Navigation or not).
We can improve the error message though.
We can improve the error message though.
[Deleted User] <[Deleted User]> #4
Ah, of course I should....
shame on me.
Improving the error message will surely help fools like me :) thanks
shame on me.
Improving the error message will surely help fools like me :) thanks
jg...@google.com <jg...@google.com> #5
We've added a better error message in https://android-review.googlesource.com/861401 and this will be available in 1.0.0-alpha10.
[Deleted User] <[Deleted User]> #6
I've tried your solution:
Tried to set left and right padding of the underlying recyclerView, like so:
(pager.getChildAt(0) as RecyclerView).apply {
//hijacking padding from pager
setPadding(
pager.paddingLeft, //resolves to 53
pager.paddingTop,
pager.paddingRight, //resolves to 53
pager.paddingBottom
)
//reseting padding on pager
pager.setPadding(0, pager.paddingTop, 0, pager.paddingBottom)
clipToPadding = false
}
got this exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.easecentral.ease.debug, PID: 23890
java.lang.IllegalStateException: Page can only be offset by a positive amount, not by -53
at androidx.viewpager2.widget.ScrollEventAdapter.updateScrollEventValues(ScrollEventAdapter.java:260)
at androidx.viewpager2.widget.ScrollEventAdapter.onScrolled(ScrollEventAdapter.java:168)
at androidx.recyclerview.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:5152)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:4212)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3843)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4385)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:511)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.widget.ScrollView.onLayout(ScrollView.java:1552)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:753)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2792)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2319)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I'll try to provide some minimum sample app, but can't promise anything right now, as I'm swarmed with other projects
Tried to set left and right padding of the underlying recyclerView, like so:
(pager.getChildAt(0) as RecyclerView).apply {
//hijacking padding from pager
setPadding(
pager.paddingLeft, //resolves to 53
pager.paddingTop,
pager.paddingRight, //resolves to 53
pager.paddingBottom
)
//reseting padding on pager
pager.setPadding(0, pager.paddingTop, 0, pager.paddingBottom)
clipToPadding = false
}
got this exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.easecentral.ease.debug, PID: 23890
java.lang.IllegalStateException: Page can only be offset by a positive amount, not by -53
at androidx.viewpager2.widget.ScrollEventAdapter.updateScrollEventValues(ScrollEventAdapter.java:260)
at androidx.viewpager2.widget.ScrollEventAdapter.onScrolled(ScrollEventAdapter.java:168)
at androidx.recyclerview.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:5152)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:4212)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3843)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4385)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:511)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.widget.ScrollView.onLayout(ScrollView.java:1552)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:753)
at android.view.View.layout(View.java:20672)
at android.view.ViewGroup.layout(ViewGroup.java:6194)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2792)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2319)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I'll try to provide some minimum sample app, but can't promise anything right now, as I'm swarmed with other projects
jg...@google.com <jg...@google.com> #7
That's our internal checks kicking-in. For now I can only offer a workaround of disabling overscroll, which I recognise is not ideal.
We'll have a look at some point - sample app will help.
Thanks again for reporting!
We'll have a look at some point - sample app will help.
Thanks again for reporting!
je...@google.com <je...@google.com>
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 450e0c3c50cb320b0f6222626034455a48aca54b
Author: Jelle Fresen <jellefresen@google.com>
Date: Tue Aug 13 10:18:41 2019
Take RV padding and item decorations into account
RecyclerView's padding and item decorations shift the position of the
current page when idle. The padding also shrinks the page size.
Bug: 139012032
Test: ./gradlew viewpager2:cC
Change-Id: Ia03646db95bb8d392408bce4d22430981c3f9171
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/BaseTest.kt
A viewpager2/src/androidTest/java/androidx/viewpager2/widget/PaddingMarginDecorationTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageChangeCallbackTest.kt
M viewpager2/src/main/java/androidx/viewpager2/widget/ScrollEventAdapter.java
M viewpager2/src/main/java/androidx/viewpager2/widget/ViewPager2.java
https://android-review.googlesource.com/1101299
https://goto.google.com/android-sha1/450e0c3c50cb320b0f6222626034455a48aca54b
Branch: androidx-master-dev
commit 450e0c3c50cb320b0f6222626034455a48aca54b
Author: Jelle Fresen <jellefresen@google.com>
Date: Tue Aug 13 10:18:41 2019
Take RV padding and item decorations into account
RecyclerView's padding and item decorations shift the position of the
current page when idle. The padding also shrinks the page size.
Bug: 139012032
Test: ./gradlew viewpager2:cC
Change-Id: Ia03646db95bb8d392408bce4d22430981c3f9171
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/BaseTest.kt
A viewpager2/src/androidTest/java/androidx/viewpager2/widget/PaddingMarginDecorationTest.kt
M viewpager2/src/androidTest/java/androidx/viewpager2/widget/PageChangeCallbackTest.kt
M viewpager2/src/main/java/androidx/viewpager2/widget/ScrollEventAdapter.java
M viewpager2/src/main/java/androidx/viewpager2/widget/ViewPager2.java
ap...@google.com <ap...@google.com> #9
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> #10
Hi, in the upcoming release of viewpager2, you will be able to set padding on RecyclerView. Note that if you have asymmetric padding, you will also need the upcoming release of recyclerview.
Closing the bug for now, but please feel free to re-open this if the suggested releases don't fix your problem, so we can continue the investigation.
Closing the bug for now, but please feel free to re-open this if the suggested releases don't fix your problem, so we can continue the investigation.
jg...@google.com <jg...@google.com> #11
beta04 will allow for a workaround (set padding in the inner RecyclerView), but we will keep this open for a long-term fix
gs...@yahoo.com <gs...@yahoo.com> #12
Who this
Description
<androidx.viewpager2.widget.ViewPager2
android:paddingEnd="20dp"
android:paddingStart="20dp"
android:clipToPadding="false" />
the padding is also applied to overscrollIndicators, which makes them not stick to the view bounds. please check the GIF attached