Растяжение двух макетов в родительском макете - PullRequest
0 голосов
/ 24 января 2012

Я пытаюсь добиться того, чтобы две вложенные относительные компоновки занимали одинаковое количество пространства И для заполнения всей ширины экрана. Все родительские макеты имеют заполнение родительского макета по ширине. Графическое представление в 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>

Ответы [ 3 ]

1 голос
/ 24 января 2012

Для двух ImageButton попробуйте установить атрибут layout_width в fill_parent, а затем добавить:

    android:scaleType="fitXY"
0 голосов
/ 24 января 2012

используйте это layout_weight = 1.в двух RelativeLayout

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        >
0 голосов
/ 24 января 2012

Чтобы получить их, используя одинаковое пространство, вы должны установить layout_weight равными числами.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...