TableLayout in HorizontalScrollView

I use the following code to create TableLayout, which can be scrolled 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"   >       
       </TableLayout>               
   </HorizontalScrollView>

I need columns in TableLayoutto at least fill the screen (i.e. if there is only one column, the borders of these columns should stretch across the screen, if there are two columns, the borders of both columns should fill the screen, etc.).

How can i do this?

+3
source share
2 answers

I had the same problem. I solved this by adding android:fillViewport="true"in HorizontalScrollView.

+10
source

Display three columns with the same 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"
    />

-1
source

All Articles