Atributo layout_weight en la etiqueta <include>
Estoy tratando de reutilizar algunos componentes de diseño en la aplicación de Android mediante la etiqueta <include>
. Tengo diferentes diseños de puertos y terrenos:
-
Puerto:
<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>
-
Tierra:
<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>
La diferencia principal es a:layout_weight="4"
, así que quiero que mi componente calc_equals_button sea más pequeño en la orientación del puerto.
La cosa es si trato de incrustar calc_equals_button
componente directamente todo funciona bien, por ejemplo:
<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>
De lo contrario – NO.
Aquí hay una muestra de 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"/>
Una limitación actual es que debe especificar layout_width y layout_height para que otros atributos layout_ * se apliquen.