如何在LinearLayout中将两个FloatingActionButton对齐在一起?

问题描述 投票:1回答:4

所以我试图在FloatingActionButton内将LinearLayout中的两个RelativeLayout对齐。像这样的东西:

<LinearLayout>
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/submitBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/DeleteBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

但是当您将它们放在TextView中时,我希望它们的行为像LinearLayout这样的其他元素。我的意思是我希望它们各自占据LinearLayout宽度的一半。但是他们会坚持[C0​​]的开始,无论我做什么,他们都不会动。

我尝试过对每个对象使用LinearLayout,但没有运气,它们根本不会移动,它们只是在android:layout_width="1"的开始处粘在一起。

外观如下:

LinearLayout

如果有任何建议,我将非常高兴!预先感谢。

android android-layout android-linearlayout floating-action-button
4个回答
0
投票
It looks like this

0
投票

请在此XML代码下面使用


0
投票

在LinearLayout中,您可以设置layout_weight = 1以共享父级:


0
投票

实现它的一种方法是这样的...

© www.soinside.com 2019 - 2024. All rights reserved.