2013-05-08 45 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> 

相关问题