Horizo​​ntalScrollView中的TableLayout

dei*_*988 4 android view tablelayout

我正在使用以下代码创建一个TableLayout可水平滚动的代码:

      <?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>
Run Code Online (Sandbox Code Playgroud)

我需要TableLayout至少填充屏幕中的列(即如果只有一列,那列的边框应该在整个屏幕上延伸,如果有两列,两列的边框应该填满屏幕等. ).

我怎样才能做到这一点?

小智 10

我有同样的问题.我通过添加android:fillViewport="true"来解决它HorizontalScrollView.