2012-09-25 51 views
1

我尝试使用滚动型和滚动型TableLayout里面像这样的工作:安卓:滚动型不TableLayout

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" > 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

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

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Input text: " /> 

      <EditText 
       android:id="@+id/weightEditText" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:inputType="numberDecimal" > 

       <requestFocus /> 
      </EditText> 
     </TableRow> 

    </TableLayout> 

</ScrollView> 

但它不工作。即使我的内容太大,滚动条也不会显示。有没有人有任何建议,为什么它这样工作?

回答

3

尝试改变滚动视图layout_height到match_parent这样的:

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_margin="10dp" > 

当您使用WRAP_CONTENT你的滚动视图只会越来越大,即使画面结束,但使用match_parent您的滚动视图时会占满屏幕,并当scrollview的内容溢出时会显示滚动条。

Rolf

+0

It works,thanks! – JavaRunner