微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

标签中的android – layout_weight属性

我正在尝试使用< 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>

土地:

<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>

主要区别是: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"/>

解决方法

当前的限制是必须为要应用的其他layout_ *属性指定layout_width和layout_height.

原文地址:https://www.jb51.cc/android/311408.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐