0

I am trying to achieve that the two nesting relative layouts take up an equal amount of space AND for the to fill out the whole width of the screen. All parent layouts have fillparent set on width. The graphical view in Eclipse looks fine, but my HTC disagrees - it glues them together (I'm fine with that) but it also shifts them to the left. I want them stretched.

  <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>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Ana
  • 23
  • 2
  • @Ana your `RelativeLayout` have their `layout_width` set to `wrap_content`. You should change that to `fill_parent` to fill all the space. – user Jan 24 '12 at 11:41
  • I really should have put it better - the two layouts are using the same amount of space, and they are stretched. Now I need to get those two ImageButtons to stretch to each of the RelativeLayouts. I have already set their width to fillparent, and height to wrap content. But they have white empty space on both sides... – Ana Jan 24 '12 at 12:11

3 Answers3

1

For the two ImageButton try to set the layout_width attribute to fill_parent and then also add:

    android:scaleType="fitXY"
user
  • 86,916
  • 18
  • 197
  • 190
0

To get them using equal space you would have to set layout_weight to equal numbers.

berlindev
  • 1,753
  • 14
  • 22
  • They use up the same space, but not the remaining space in the row... I need to stretch them both to the parent. – Ana Jan 24 '12 at 12:00
0

use this layout_weight=1. in two RelativeLayout

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        >
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98
  • This does not solve the issue. Now the first one is set at the beginning of the row, and the other one at the center of the row; both have empty space after them. – Ana Jan 24 '12 at 11:57
  • use linearlayout in place of RelativeLayout. why useing RelativeLayout any reason? – NagarjunaReddy Jan 24 '12 at 12:24
  • Not my code and am not really "allowed" to make random changes. Seems stupid, and it is. – Ana Jan 24 '12 at 14:32