2017-08-11 29 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 –

相關問題