Java 如何与Linearlayout和weight参数正确对齐?

Java 如何与Linearlayout和weight参数正确对齐?,java,android,xml,layout,android-linearlayout,Java,Android,Xml,Layout,Android Linearlayout,我需要知道如何对齐最后三个按钮,以便根据上面的按钮对齐 我要给你们看一个屏幕截图,关于我说的 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="5" android:orientation="horizontal">

我需要知道如何对齐最后三个按钮,以便根据上面的按钮对齐

我要给你们看一个屏幕截图,关于我说的

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:weightSum="5"
            android:orientation="horizontal">

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="24dp"
                android:layout_weight="4"
                android:text="@string/b_zero" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="24dp"
                android:layout_weight="1"
                android:text="@string/b_punto" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="24dp"
                android:layout_weight="1"
                android:text="@string/b_signo_mas" />


</LinearLayout>




正如您所看到的,我希望使用权重参数将组合两列的零按钮对齐。

您可以通过指定一个
android:layoutSum=4
然后将权重作为2/1/1分布在子视图中来实现该分布。确保为每个子级指定android:layout_width=0dp


使用
android:layout\u weight
属性时,请始终记住将
0dp
作为与指定权重的方向相对应的维度。

可以通过指定
android:layoutSum=4
然后在子视图中以2/1/1的形式分配权重来实现该分布。确保为每个子级指定android:layout_width=0dp


当使用
android:layout\u weight
属性时,请始终记住将
0dp
作为与指定权重的方向相对应的维度。

如何
android:weightSum=4
然后将2/1/1分布与
android:layou width=0dp
一起使用。很酷,谢谢你,它工作得非常好@shaishaver!就是这样吗?是的,我不知道每个按钮都需要输入witdh的0dp。关于
android:weightSum=4
,然后是2/1/1分布以及
android:layout\u width=0dp
。很酷,谢谢你,伙计,它在@shaishavy>上运行得非常好!是吗?是的,我不知道在每个按钮上都需要放置0 DP的witdh