我正在尝试使用<include>标记在android应用程序中重用一些布局组件.我有不同的港口和土地布局:
港口:
<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>
Run Code Online (Sandbox Code Playgroud)土地:
<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>
Run Code Online (Sandbox Code Playgroud)主要的区别是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>
Run Code Online (Sandbox Code Playgroud)
否则 - 不是.
以下是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"/>
Run Code Online (Sandbox Code Playgroud)
Rom*_*Guy 26
当前的限制是您必须为要应用的其他layout_*属性指定layout_width和layout_height.
| 归档时间: |
|
| 查看次数: |
1924 次 |
| 最近记录: |