在父布局中拉伸两个布局

问题描述 投票:0回答:3

我试图实现两个嵌套相对布局占用相等的空间并且用于填充整个屏幕宽度。所有父布局都在fillparent的宽度上设置。 Eclipse中的图形视图看起来很好,但我的HTC不同意 - 它将它们粘合在一起(我很好),但它也将它们移到左边。我希望他们伸展。

  <LinearLayout
        android:id="@+id/footer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <RelativeLayout
            android:id="@+id/relativeLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            >

            <ImageButton
                android:id="@+id/button_1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent"
                android:src="@drawable/button_1_active" >
            </ImageButton>

            <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/partners_info"
                android:textColor="@color/white"
                android:textStyle="bold" >
            </TextView>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/relativeLayout2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             >

            <ImageButton
                android:id="@+id/button_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent"
                android:src="@drawable/button_2_inactive" >
            </ImageButton>

            <TextView
                android:id="@+id/TextView02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="@string/partners_map"
                android:textColor="@color/white"
                android:textStyle="bold" >
            </TextView>
        </RelativeLayout>
    </LinearLayout>
android android-layout alignment fill-parent
3个回答
1
投票

对于两个ImageButton尝试将layout_width属性设置为fill_parent然后还添加:

    android:scaleType="fitXY"

0
投票

要使用相等的空间来获得它们,您必须将layout_weight设置为相等的数字。


0
投票

使用此layout_weight = 1。在两个RelativeLayout中

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        >
© www.soinside.com 2019 - 2024. All rights reserved.