Подтвердить что ты не робот

Атрибут layout_weight в теге <include>

Я пытаюсь повторно использовать некоторые компоненты компоновки в приложении Android с помощью тега <include>. У меня разные схемы расположения портов и земли:

  • Порт:

    <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
    
        <include layout="@layout/calc_equals_button" a:layout_weight="4"/>
        <include layout="@layout/calc_display"/>
    
    </LinearLayout>
    
  • Земля:

    <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
    
        <include layout="@layout/calc_equals_button"/>
        <include layout="@layout/calc_display"/>
    
    </LinearLayout>
    

Основное отличие a:layout_weight="4", поэтому я хочу, чтобы мой компонент calc_equals_button был меньше в ориентации порта.

Дело в том, что если я пытаюсь встроить компонент calc_equals_button, все работает нормально, например:

<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
        <DirectionDragButton
                xmlns:a="http://schemas.android.com/apk/res/android"
                a:id="@+id/equalsButton"
                a:text="="
                a:layout_width="match_parent"
                a:layout_height="match_parent"
                a:layout_weight="4"
                style="@style/control_button_style"
                a:onClick="numericButtonClickHandler"/>

        <include layout="@layout/calc_display"/>

    </LinearLayout>

иначе - НЕ.

Вот пример calc_equals_button.xml:

<DirectionDragButton
    xmlns:a="http://schemas.android.com/apk/res/android"
    a:id="@+id/equalsButton"
    a:text="="
    a:layout_width="match_parent"
    a:layout_height="match_parent"
    style="@style/control_button_style"
    a:onClick="numericButtonClickHandler"/>
4b9b3361

Ответ 1

В настоящее время ограничение на то, что вы должны указать layout_width и layout_height для других атрибутов layout_ *, которые будут применяться.