Bug P3
Status Update
Comments
[Deleted User] <[Deleted User]> #2
I face with the same problem. I have different pageMargin in landscape and portrait and when viewpager is scrolled for the more than first position, after rotating device it is shifted.
I beleive the problem is inside onSizeChanged that is called after onConfigurationChanged, it has following code:
if (w != oldw) {
recomputeScrollPosition(w, oldw, mPageMargin, mPageMargin);
}
w always not equals oldw when changing orientation, so recomputeScrollPosition is called, but whit the same values for margin and oldMargin.
This should be fixed.
I beleive the problem is inside onSizeChanged that is called after onConfigurationChanged, it has following code:
if (w != oldw) {
recomputeScrollPosition(w, oldw, mPageMargin, mPageMargin);
}
w always not equals oldw when changing orientation, so recomputeScrollPosition is called, but whit the same values for margin and oldMargin.
This should be fixed.
Description
Version used: androidx.appcompat:appcompat:1.1.0, com.google.android.material:material:1.2.0-alpha06, androidx.recyclerview:recyclerview:1.1.0
Devices/Android versions reproduced on: Moto G 1st Gen Lollipop 5.1 (have not tested this on other devices, yet).
I have a ViewPager with multiple tabs/fragments. Each fragment contains a single RecyclerView and nothing else. When the device language is LTR, and I swipe left and right, I can navigate properly between the tab. No issues at all on LTR.
Though, when I switch to RTL (Arabic for example) on device language, I can swipe properly on a single direction, but when I attempt to swipe into the other direction, the RecyclerView item gets focus and gets clicked resulting in failing the swipe. Note that my RV items do not offer swipe actions at all. They offer click and long click support only.
I have traced this issue to the canScroll() method inside ViewPager.java. I am referring to the one used inside onInterceptTouchEvent(). On proper swipes on LTR, canScroll() is always false. It is also false on one of the swipe directions (the one that works).
On the other hand, if I do not swipe on any of the RV items, on RTL, (e.g. swiping on the empty area to the bottom of a RecyclerView with low number of items), everything works fine on both swipe directions.
I do not understand how this canScroll() works exactly, and do not get how RTL can affect it.
Thanks for your time.