标签中的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.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...