简体   繁体   中英

Android: How to implement a Vertical scroll view with Multiple Horizontal rows inside of it?

在此处输入图片说明

strong text

Hi All, I need to get some help to implement implement a Vertical scroll view with Multiple Horizontal rows inside of it, this is what I have so far, any help or hint would be highly appreciated

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TableLayout android:id="@+id/threeByThreeTable" android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="0,1,2" android:padding="10dp" > <TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" > <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/mygallery1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" /> </HorizontalScrollView> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" > <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/mygallery2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" /> </HorizontalScrollView> </TableRow> <TableRow android:id="@+id/tableRow3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" > <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/mygallery3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" /> </HorizontalScrollView> </TableRow> </TableLayout> </ScrollView> 

Put your TableLayout inside a ScrollView instead of a LinearLayout. Just keep in mind that a ScrollView can only have one child.

Why not just use a ListView and remove the lines between the items? Seems like that would work much better than rolling your own view

  • Put a Vertical Linear Layout inside your ScrollView
  • Inside the vertical linear layout, create your HorizontalScrollViews.

It should work probably, please let me know if you have questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM