WRAP_CONTENT填充父级

时间:2011-10-27 17:28:41

标签: android android-layout

我有几个带有控件的活动,我想要包装内容,但出于某种原因,它们最终会填充父级。使用层次结构查看器检查它们会在设置WRAP_CONTENT时显示它们,但视图的边界框清楚地占据了屏幕上的其余空间。

上面概述了视图,正如您所看到的,layout_width是WRAP_CONTENT,但它填满了屏幕。是的,我已经检查过,它的子LinearLayout没有填充宽度 - 它的结尾是它的父节点。

编辑:图片真的只是为了展示视图最终的布局。这是XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
<TableLayout android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignParentLeft="true"
             android:id="@+id/cart_table">
    <TableRow android:layout_height="wrap_content"
              android:id="@+id/footer">
        <View android:layout_height="0dp" />
        <TextView android:textSize="@dimen/h2"
                  android:gravity="right"
                  android:id="@+id/grand_total" />
    </TableRow>
</TableLayout>
<com.eftours.TDLinkv2.Payment.Controls.PaymentForm
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/cart_table"
            android:layout_alignParentRight="true"
            android:id="@+id/payment_form" />
<Button android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/small_button"
        android:layout_below="@id/payment_form"
        android:id="@+id/checkout_button"
        android:text="Checkout" />

0 个答案:

没有答案
相关问题