0

我使用的是水平滾動查看內部的循環器視圖來顯示像下面螺紋評論:RecyclerView Horizo​​ntalScrollView的Android內部

註釋1 Comment1Child1 Comment1Child2 Comment1Child2Child1 Comment1Child3註釋2

我使用以下XML完成了此操作:

<HorizontalScrollView 
       android:id="@+id/horizontalScrollView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:fillViewport="true" 
       android:scrollbarSize="2dp"> 

       <android.support.v7.widget.RecyclerView 
        android:id="@+id/commentRV" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentStart="true" 
        android:layout_marginLeft="47dp" 
        android:minWidth="200dp" /> 
      </HorizontalScrollView> 

您會看到我設置了200dp的最小寬度,以便評論永遠不會太小,並且越靠近他們離線的線程越深。

它顯示完美,但我無法水平滾動。我可以看到滾動條,但不能水平滾動。

我已經擺弄RV禁用Touch和nestedScrollingEnabled,但不知道真正的解決方案是什麼。似乎沒有任何工作?

任何幫助將不勝感激!謝謝

+0

您可以簡單地使用'LayoutManager'爲'RecyclerView'。無需使用'Horizo​​ntalScrollView' – Piyush

+0

@Piyush我正在使用LayoutManager,但我需要RV在Horizo​​ntalScroll內,否則它將無法工作 – SuperBale

回答

2

刪除​​LinearLayoutManager`與水平方向這樣

LinearLayoutManager layoutManager= new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); 

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); 
reclyclerView.setLayoutManager(layoutManager); 
//recyclerView.setMinimumWidth(200); optional for width if u need 
+0

我不知道這是如何幫助不幸的?我試圖讓它滾動。它顯示正確 – SuperBale

+0

工作! 'Horizo​​ntalScrollview'不是必需的。設置'LinearLayoutManager.HORIZONTAL'工作得很好。謝謝! – mrudult

+0

@mrudult享受編碼... –