2014-10-17 69 views
0

我正在研究包含表格和行的android應用程序。每一行都會有三個值。問題是這些值是如此接近對方,我想增加他們之間的空間,讓每一個將其列以上,這樣的:Android增加單詞間距

enter image description here

,但它顯示是這樣的:

enter image description here

這裏是在XML文件中的表格佈局:

<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TableRow> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="name" 
      android:layout_weight="1" /> 


     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="email" 
      android:layout_weight="1" /> 

      <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="password" 
      android:layout_weight="1" /> 

    </TableRow> 
     <TextView 
      android:id="@+id/user_info" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="get user info"/> 
</TableLayout> 

,這中形成在Java文件中的用戶的:

String userData = "" + Html.fromHtml(userName + userEmail + userPassword); 

回答

0

代替單個TextView與級聯的所有字符串,只需添加含有第二TableRow三個單獨TextView控制,就像第一個。

這樣他們應該類似對齊。

0

更新的代碼在這裏:

<TableLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<TableRow> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="name" 
     android:layout_weight="1" /> 


    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="email" 
     android:layout_weight="1" /> 

     <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="password" 
     android:layout_weight="1" /> 

</TableRow> 
    <TextView 
     android:id="@+id/user_name" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="get user info"/> 
    <TextView 
     android:id="@+id/user_email" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="get user info"/> 
    <TextView 
     android:id="@+id/user_password" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="get user info"/> 
</TableRow> 
</TableLayout> 

因此,這將在每個視圖表佈局對齊每一個項目。考慮這個問題的好方法是你創建一個n×n矩陣。