2017-08-11 139 views
10

其实我目前正在为AndroidTV应用程序工作。我有多个横向RecyclerView从右到左NestedScrollView像这样的形象。NestedScrollView内部多个水平RecyclerView窃取焦点

问题是,当我向左滚动更多时,焦点移动到不同的列表或不同的视图,这是不好的。

我不想让焦点改变。如果列表到达最后,那么焦点应该保持在相同的位置。

我想:

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

但它没有工作..

谁能帮助我?

enter image description here

没有解决

+0

请尝试下面的解决方案在这[相关SO帖子](https://stackoverflow.com/a/42688298/5995040) –

+0

已经尝试过,但没有帮助@Rebot –

+0

我解决了我的问题与使用android:descendantFocusability = “blocksDescendants”用于滚动视图中的根布局。也使用nestedscrollview而不是scrollview。 – asozcan

回答

0

试着改变你的ScrollViewNestedScrollView。这背后的一个原因是

**NestedScrollView** 

NestedScrollView就像滚动型,但它支持作为 两个嵌套滚动父母和孩子在新的和旧的Android版本 。嵌套滚动默认启用。

**ScrollView** 

为能够由用户 滚动,允许它比物理显示器大视图层次布局容器。 ScrollView 是一个FrameLayout,这意味着你应该在其中放置一个包含 内容的子项来滚动;这个孩子本身可能是一个布局 经理与一个复杂的对象层次结构

这将帮助您确定哪个布局正在聚焦。

+0

我已经使用NestedScrollView但没有帮助... @Dipali shah –

+0

有问题,你已经提到你的'Recyclerview'是'ScrollView'里面的 –

+0

对不起,我没有更新我的问题。 –

0

您可以使用下面的结构嵌套滚动

<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> 

我希望这将有助于!

+0

对不起,它没有改变任何东西。谢谢你的帮助.. @Alpesh Sorathiya –

相关问题