Вес макета Android

Я новичок в разработке Android, и у меня есть вопрос о настройке веса в линейном макете.

Я пытаюсь создать строку с двумя настраиваемыми кнопками и настраиваемым текстом редактирования. Текст редактирования должен занимать ровно столько места, сколько его содержимое, а две кнопки должны расширяться по горизонтали, чтобы заполнить остальную часть доступного пространства в строке. Нравится...

| [#Button++#] [#Button--#] [et] |

После нескольких попыток это самое близкое к тому, что я могу получить, хотя это кажется слишком сложным.

| [Button] [Button] [###ET###] |

<LinearLayout 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal|center_vertical"
    android:layout_weight="1"
    >

    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal|center_vertical"
        >
        <RelativeLayout 
            android:id="@+id/btn_plus_container" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            >
            <ImageButton 
                android:layout_height="wrap_content"
                android:layout_width="fill_parent" 
                android:id="@+id/btn_plus" 
                android:background="@drawable/btn"
                android:layout_centerInParent="true"
                ></ImageButton>
            <TextView 
                android:textColor="#FAFAF4"
                android:id="@+id/tv_dice_plus" 
                android:text="@string/tv_plus" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                ></TextView>
        </RelativeLayout>
    </LinearLayout>
    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal|center_vertical"
        >
        <RelativeLayout 
            android:id="@+id/btn_minus_container" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            >
            <ImageButton 
                android:layout_height="wrap_content"
                android:layout_width="fill_parent" 
                android:id="@+id/btn_minus" 
                android:background="@drawable/btn"
                android:layout_centerInParent="true"
                ></ImageButton>
            <TextView 
                android:textColor="#FAFAF4"
                android:id="@+id/btn_minus" 
                android:text="@string/tv_minus" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                ></TextView>
        </RelativeLayout>
    </LinearLayout>
    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal|center_vertical"
        >
        <EditText 
            android:textColor="#FAFAF4"
            android:text="@string/et_output" 
            android:id="@+id/et_output" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:inputType="number"
            android:selectAllOnFocus="true" 
            android:minWidth="50sp"         
            android:maxWidth="50sp"
            android:background="@drawable/tv_black_background3"
            android:textColorHighlight="#c30505"
            ></EditText>
    </LinearLayout>
</LinearLayout>

Насколько я понимаю, настройка [android: layout_weight = "2"] для линейных макетов с удержанием кнопок должна сделать они занимают больше места, чем редактируемый текст, но для меня происходит обратное, делая их вдвое меньше.

| [Btn] [Btn] [#####et#####] |

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

84
задан Cristian 13 February 2011 в 21:08
поделиться