2011-06-28 18 views
48

ご覧ください:スクロール可能なTableLayoutを作成するには?ここでのXMLコードで

<TableLayout 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="10dip" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <TableRow 
    android:id="@+id/tableRow1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <!-- Some stuff goes here --> 

    /> 
    </TableRow> 

    <TableRow 
    android:id="@+id/tableRow2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <!-- Some stuff goes here --> 

    /> 
    </TableRow> 

    <TableRow 
    android:id="@+id/tableRow3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <!-- Some stuff goes here --> 

    /> 
    </TableRow> 


</TableLayout> 

私のコードは、はるかに長いよりもあるんだけど、不要な部分を排除しました。 問題は私がこれをTableLayoutにスクロール可能にして、すべてのものを表示できるようにすることです。

私はそれをスクロール可能にするためにTableLayoutにこの行を入れてみました:

android:isScrollContainer="true" 

しかし、それは仕事をしません。 方法はありますか?

答えて

92

包むに全部:あなたが技術的にScrollViewでのLinearLayoutを必要としない

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scrollbars="none" 
    android:layout_weight="1"> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 

    ... 

</ScrollView> 
+1

非常に非常にワーキングソリューションをTableLayout。ありがとう:) – iTurki

+1

@citizenなぜ 'LinearLayout'ですか? – Sudhanshu

+0

@Sudhanshuこの投稿は3年前ですが、私が覚えている限り、向きを垂直に設定する最も基本的なラッパーです。 –

12

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:scrollbars="none" 
android:layout_weight="1"> 

    <TableLayout 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="10dip" 
    android:isScrollContainer="true"> 

    <TableRow 
    android:id="@+id/tableRow1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

     <--!Everything Else You Already Have--> 

    </TableRow> 
</TableLayout> 
</ScrollView> 

あなたはScrollView、スクロール効果内に十分なスペースを取るたら十分な行のテキストがあれば、HTML TextAreaのようなものがアクティブになります。

また、ScrollViをネストすることもできますew、ただし、ScrollViewに十分なコンテンツがあるまで、スクロール効果を感じることはできません。

0

おかげで、それは私が

  • ScrollView終了と
  • のLinearLayout
  • XのTableRow(列のヘッダーのための)最後に順番に

    1. TableLayout
    2. のTableRowを置く私の問題 を解決していますmbauer
    3. end LinearLayout
    4. エンドScrollView
    5. エンドは
  • +0

    しないでください! 「2. Table Row」の列幅が「5. x TableRow」の列幅と一致しませんでした。 – AnViKo

    関連する問題