-2

我终于通过权重属性解决了我上一个帖子的问题,但是当我最后给出多行文本时出现了一个问题 Textview not show which in this url http://imgur.com/ApL5c

如何在我的代码中添加滚动视图?

<?xml version="1.0" encoding="utf-8"?>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content"
  android:stretchColumns="1" 
   android:weightSum="11"
  android:layout_margin="5dp">

   <TableRow>         
     <TextView 
        style="@style/StyleLabel"
        android:text="@string/name_lbl"/>
     <TextView 
        android:id="@+id/nameText" 
         android:layout_weight="2"

        style="@style/StyleText"/>         
  </TableRow>

  <TableRow>         
     <TextView 
        style="@style/StyleLabel"

        android:text="@string/cap_lbl"/>         
     <TextView 
        android:id="@+id/capText"

         android:layout_weight="2"
        style="@style/StyleText"/>         
  </TableRow>

  <TableRow>         
     <TextView 
        style="@style/StyleLabel"
        android:text="@string/code_lbl"/>         
     <TextView 
        android:id="@+id/codeText"

         android:layout_weight="1"
        style="@style/StyleText"/>         
  </TableRow>




    <TableRow>         
     <TextView 
        style="@style/StyleLabel"
        android:text="@string/DoneDate_lbl"/>         
     <TextView 
        android:id="@+id/Location_lbl"
         android:layout_weight="1"

        style="@style/StyleText"/>         
  </TableRow>











     <TableRow>         
     <TextView 

        style="@style/StyleLabel"
        android:text="@string/Notes_lbl"/>         
     <TextView 



        android:id="@+id/Notes_lbl"
         android:layout_weight="4"
        style="@style/StyleText"







        />         
  </TableRow>







   <TableRow>         
     <TextView 
        style="@style/StyleLabel"
        android:text="@string/person_lbl"/>         
     <TextView 
        android:id="@+id/Person_lbl"
         android:layout_weight="1"

        style="@style/StyleText"/>         
  </TableRow>

4

1 回答 1

0

只需将其包围在滚动视图中,如下所示 -

<ScrollView 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android" >

<TableLayout 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content"
  android:stretchColumns="1" 
   android:weightSum="11"
  android:layout_margin="5dp">
<TableRow>         
     <TextView 

        android:text="textview1"/>
     <TextView 
        android:id="@+id/nameText"
        android:text="tewgoijirtgujerioug"
        android:lines="15" //You can add lines to make your textview occupy the no of lines you want instead of weight. 
         android:layout_weight="2"

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

希望这可以帮助。

于 2012-12-11T11:24:25.317 回答