2013-05-08 44 views
0

我想在我的應用程序中創建ala瓷磚地圖。不幸的是,TextView的寬度並不相等,因爲它解決了嗎?TableLayout中的等值TextView

This is my layout

+0

至於我也明白了,這個問題可能是由於這樣的事實,你已經把機器人:layout_width =「match_parent」,嘗試給它一個值以符合您的需求 – Abx 2013-05-08 08:19:12

+0

hi Artur,welcome對社區來說,你能否詳細描述一下你的問題? – stinepike 2013-05-08 08:19:41

+0

我不認爲它是一個好主意來模仿其他UI元素,就像在這裏的Android設計指南中所說:http://developer.android.com/design/patterns/pure-android.html – sandkasten 2013-05-08 08:20:25

回答

0

使用android:weightSum和android:layout_weight

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

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:weightSum="4" > 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="1dp" 
      android:layout_weight="2" 
      android:background="#B0B0B0" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="1dp" 
      android:layout_weight="2" 
      android:background="#B0B0B0" /> 

    </TableRow> 

</TableLayout> 

相關問題