Obsolete
Status Update
Comments
al...@android.com <al...@android.com>
vi...@gmail.com <vi...@gmail.com> #2
We are having the same problem Yigit.
Our MainActivity has a Fragment that contains a vertical RecyclerView (which is inside a SwipeRefreshLayout that is in turn inside a CoordinatorLayout; we also have an AppBarLayout). Each item of the vertical RecyclerView contains an horizontal RecyclerView, like the Android TV app.
When we upgrade the support libs from 23.4.0 to 24.0.0 the automatic scroll suddenly appears. In particular, when we open an Activity on top of the MainActivity and we then go back, the vertical RecyclerView scrolls up so that the horizontal RecyclerView does not get cut and the row is displayed completely.
It sucks. What can we do?
Thanks!
Our MainActivity has a Fragment that contains a vertical RecyclerView (which is inside a SwipeRefreshLayout that is in turn inside a CoordinatorLayout; we also have an AppBarLayout). Each item of the vertical RecyclerView contains an horizontal RecyclerView, like the Android TV app.
When we upgrade the support libs from 23.4.0 to 24.0.0 the automatic scroll suddenly appears. In particular, when we open an Activity on top of the MainActivity and we then go back, the vertical RecyclerView scrolls up so that the horizontal RecyclerView does not get cut and the row is displayed completely.
It sucks. What can we do?
Thanks!
vi...@gmail.com <vi...@gmail.com> #3
I've found the solution in these Stack Overflow questions:
http://stackoverflow.com/q/37968010/4034572
http://stackoverflow.com/q/38949034/4034572
http://stackoverflow.com/q/36923948/4034572
There are 2 ways to solve this.
1) This is the simplest. Simply add android:descendantFocusability="blocksDescendants" to your outer RecyclerView.
2) If your outer RecyclerView is contained in another layout (like a FrameLayout as we have), add android:focusableInTouchMode="true" to this other layout.
There are 2 ways to solve this.
1) This is the simplest. Simply add android:descendantFocusability="blocksDescendants" to your outer RecyclerView.
2) If your outer RecyclerView is contained in another layout (like a FrameLayout as we have), add android:focusableInTouchMode="true" to this other layout.
[Deleted User] <[Deleted User]> #4
For me, the solution is to override GridLayoutManager.onRequestChildFocus() to always return true, since when we change tab, the RecyclerView is requesting its child to focus, and somehow it involves scrolling the RecyclerView.
ki...@google.com <ki...@google.com> #5
Can somebody that is experiencing this issue attach a small complete app that reproduces this behavior under the latest 25.4.0 builds of support library?
al...@gmail.com <al...@gmail.com> #6
This is still happening with support lib 26.0.1
ki...@google.com <ki...@google.com> #7
No sample app provided. Closing as obsolete. Reopen if this is happening with a small complete app.
Description
Version used:24.0.0 or higher
Theme used:
Devices/Android versions reproduced on: Oneplus One, Xiaomi Mi2, both Android 6.0.1
I'm using CoordinatorLayout, ViewPager with RecyclerView to display multiple CardViews. Here are the xml files:
The activity :
<android.support.design.widget.CoordinatorLayout xmlns:android="
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
style="@style/Fab"
android:src="@drawable/ic_create_white_24dp"
app:layout_anchor="@+id/view_pager"
app:layout_anchorGravity="bottom|right|end"
app:layout_behavior="me.wuke.boo.ui.custom.ScrollAwareFABBehavior" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:titleTextAppearance="@style/ToolbarTitle"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
app:tabMode="scrollable"
style="@style/TabLayout.Dark" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
ViewPagers only handles fragments with a RecyclerView inside, so I'd post CardViews used in the RecyclerView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
android:id="@+id/generic_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingTop="16dp">
<include layout="@layout/layout_user_info" />
<me.wuke.boo.ui.custom.ClickableTextView
android:id="@+id/text"
style="@style/TextView.Body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:paddingTop="4dp"/>
<!--android:layout_marginStart="52dp"/>-->
<RelativeLayout
android:id="@+id/other_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="4dp">
<!--android:paddingStart="52dp">-->
<android.support.v7.widget.RecyclerView
android:id="@+id/thumbnails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="8dp" />
<!--irrelevant views-->
</RelativeLayout>
</LinearLayout>
As you can see the CardView contains a RecyclerView to display thumbnails.
With following conditions:
1.Start another Activity then go back to this one.
2.The RecyclerView stops at a position that a nested RecyclerView (android:id="@+id/thumbnails") in a CardView is partly displayed, as shown in the first screenshot.
3.Switch among fragments of the ViewPager.
When I switch back to the fragment, it automatically scrolls up until the inner RecyclerView of thumbnails is fully displayed. Then if I scroll down a little bit, then switch to another fragment and swipe back, it automatically scrolls again. I only get this bug with Support Library 24.0.0 or higher.