15

Actually I'm currently working for a AndroidTV app. I have multiple horizontal RecyclerView right to left inside a NestedScrollView like that image.

Problem is that when I scroll more towards left, then focus moves to different list or different view which is not good.

I don't want the focus to change. If the list reaches to the end, then focus should remain at same position.

I tried :

android:descendantFocusability="blocksDescendants"
android:focusableInTouchMode="true" //in parent layout

But it didn't work..

Can anyone help me out ??

enter image description here

Not solved

Puspak Ghosh
  • 171
  • 1
  • 10
  • Try following the solution in this [related SO post](https://stackoverflow.com/a/42688298/5995040) – Mr.Rebot Aug 13 '17 at 00:48
  • Already tried but not helpful @Mr.Rebot – Puspak Ghosh Aug 13 '17 at 19:22
  • I solved my problem with using android:descendantFocusability="blocksDescendants" for root layout in the scrollview. Also using nestedscrollview instead of scrollview. – asozcan Sep 20 '17 at 15:53
  • i also tried that android:descendantFocusability="blocksDescendants" in my root layout in the ScrollView but after it use focus not detect in RecyclerView's child. @asozcan – Puspak Ghosh Sep 21 '17 at 07:13
  • 1
    just wondering, have you solved this problem? I'm facing same issue right now – A. N Aug 30 '18 at 03:33
  • Not at all but we can say 80% solved..Flow the steps.. 1.Take ScrollView as a root 2. Use in that root android:focusable="false" android:focusableInTouchMode="false" android:descendantFocusability="blocksDescendants" 3. At child layout's root element use android:clickable="true" android:focusable="true" Follow those steps and let me know... @Kyk – Puspak Ghosh Aug 31 '18 at 05:03

3 Answers3

0

Try changing your ScrollView to NestedScrollView. A reason behind this is

**NestedScrollView**

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

**ScrollView**

Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects

This will help you to determine which layout is being focused.

Dipali Shah
  • 3,742
  • 32
  • 47
0

You can use below structure for nested scroll

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:clickable="false"
    android:orientation="vertical">

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scroll_search_all"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:isScrollContainer="false"
                    android:nestedScrollingEnabled="false" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:isScrollContainer="false"
                    android:nestedScrollingEnabled="false" />

            </LinearLayout>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</FrameLayout>

I hope this will help!

Alpesh Sorathiya
  • 510
  • 3
  • 13
0

Try using this one code in your recycleview section 2:

android:layoutDirection="rtl"
Mureinik
  • 297,002
  • 52
  • 306
  • 350