TableLayout within HorizontalScrollView
I am using following code to create a TableLayout
which is scrollable horizontally:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="200dp"
android:scrollbars="none">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/maintable2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*"
android:background ="#dddddd"
android:scrollbars="none" >
</Table开发者_如何转开发Layout>
</HorizontalScrollView>
I need the columns in the TableLayout
to at least fill the screen (i.e. if there is only one column, the borders of that columns should stretch over the whole screen, if there are two columns, the borders of both columns should fill the screen etc.).
How can I do that?
I had the same problem. I solved it by adding android:fillViewport="true"
to the HorizontalScrollView
.
Showing three columns with equal size next to each other
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background ="#dddddd"
/>
<TableLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
/>
<TableLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background ="#dddddd"
/>
精彩评论