1

我想同時實現一個Recycler視圖的水平和垂直滾動。我必須顯示一個8列的表,所以我打算實現同樣的水平和垂直滾動時間。Android:水平和垂直滾動recyclerview

我試過Horizo​​ntalScrollView但它是在一行中水平滾動。

list_row.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:focusable="true" 
android:clickable="true" 
android:background="?android:attr/selectableItemBackground" 
android:orientation="vertical"> 

<HorizontalScrollView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
    > 
    <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 
    <TextView 
    android:id="@+id/title" 
    android:textColor="@color/title" 
    android:textSize="16dp" 
    android:textStyle="bold" 
    android:layout_alignParentTop="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="aaa"/> 

<TextView 
    android:id="@+id/genre" 
    android:layout_below="@id/title" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="20dp" 
    android:text="bbb"/> 

<TextView 
    android:id="@+id/year" 
    android:textColor="@color/year" 
    android:layout_width="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="20dp" 
    android:text="ccc"/> 
    </LinearLayout> 
</HorizontalScrollView> 
</RelativeLayout> 

是有任何方式由整個表在相同的佈局水平和垂直滾動的列表。

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" > 
    <HorizontalScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fillViewport="true" > 
    </HorizontalScrollView> 
</ScrollView> 

已經閱讀在回答問題:

+0

你需要一個'RecyclerView'與表LayoutManager –

+0

試試這個..希望這會幫助你... http://code2care.org/pages/make-android-view-scrollable-both-horizo​​ntally-and-vertically/ –

回答