【发布时间】:2020-05-19 10:31:13
【问题描述】:
所以我试图在LinearLayout 中对齐FloatingActionButton 中的两个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>
但是当您将它们放在LinearLayout 中时,我希望它们的行为与TextView 之类的任何其他元素一样。
我的意思是我希望它们每个都占据LinearLayout 宽度的一半。
但是他们会坚持LinearLayout的起点,无论我怎么尝试,他们都不会移动。
我尝试在它们每个上都使用android:layout_width="1",但没有运气,它们根本不会移动,它们只是在LinearLayout 的开头粘在一起。
它的外观如下:
如果有任何建议,我会很高兴!提前致谢。
【问题讨论】:
-
你想要一个浮动按钮在左侧,另一个在右侧正确吗?
-
@PraveenSP 是的,宽度均匀
-
设置
layout_weight1 在他们和重力为Start。试试看 -
@LalitFauzdar 不,没用!
标签: android android-layout android-linearlayout floating-action-button