Размер кнопки для разделения процента 10:90 - PullRequest
0 голосов
/ 09 ноября 2018

В Android Studio у меня есть две кнопки, которые имеют одинаковый размер в нижней части упражнения. Как я могу сделать кнопку № 1 около 10% с кнопкой № 2 на 90%, чтобы заполнить дно? Вот что у меня пока ...:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    tools:context=".MainActivity">

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_marginTop="2dp"
        android:layout_marginLeft="2dp"
        android:layout_marginRight="2dp"
        android:layout_marginBottom="2dp">

        <!-- Button # 1-->
        <Button
            android:id="@+id/btnUp"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="UP" />

        <!-- Button # 2-->
        <Button
            android:id="@+id/btnWMS"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/colorActiveBtn"
            android:text="XYZ" />

    </TableRow>

</RelativeLayout>

Ответы [ 2 ]

0 голосов
/ 09 ноября 2018

Изменить вес 2-й кнопки:

android:layout_weight="9"

Поскольку 1-й имеет android:layout_weight="1", вы получите то, что хотите.

0 голосов
/ 09 ноября 2018

Вы можете добавить вес своим кнопкам, используя атрибут weightSum на родительском элементе.

<LinearLayout
    ....
    android:orientation="horizontal"
    android:weightSum="10">
    <Button
        ...
        android:layout_weight="1"/>
    <Button
        ...
        android:layout_weight="9"/>
</LinearLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...