layout_weight以外的任何其他属性会使一个元素占用比其他元素更多的空间吗?

时间:2014-09-27 20:52:15

标签: android tablerow android-layout-weight

这个问题是基于我的另一个问题。 Why is each element in the table row still taking the same amount of space

问题不在于按钮的默认边距或layout_width属性。是否只有表行的一些属性不会让layout_weight工作?如果是这样,我是否可以使用任何其他属性来处理此问题。我知道我不能使用layout_span,因为它涉及两行。

1 个答案:

答案 0 :(得分:0)

检查一下是否有效..

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" >

<TextView
    android:id="@+id/stockView"
    android:layout_width="0dip"
    android:text="TextView"
    android:layout_weight="2" />

<Button
    android:id="@+id/stockQuote"
    android:layout_width="0dip"
    style="?android:attr/buttonStyleSmall"
    android:text="get_stock_quote"
    android:layout_weight="1" />

<Button
    android:id="@+id/webStock"
    android:layout_width="0dip"
    style="?android:attr/buttonStyleSmall"
    android:text="go_to_website"
    android:layout_weight="1"  />