如何解决FloatingActionsButtons平均分配到全宽
我想在整个宽度上均匀分布6个按钮,因此它们之间的空间都相同。 AndroidStudio Design如下所示:
但是在我的设备上,它看起来像这样:
我在做什么错了?
LinearLayout:
<LinearLayout
android:id="@+id/horizontal_buttons_timeline"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="6">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/action_previous_timeline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_weight="1"
android:contentDescription=""
app:fabCustomSize="@dimen/fab_size"
app:maxImageSize="@dimen/fab_image_max_size"
android:src="@drawable/ic_previous"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/action_bookmark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_weight="1"
app:fabCustomSize="@dimen/fab_size"
app:maxImageSize="@dimen/fab_image_max_size"
android:contentDescription="@string/mainmenubookmark_de"
android:src="@drawable/ic_bookmark" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/action_search_timeline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_weight="1"
app:fabCustomSize="@dimen/fab_size"
app:maxImageSize="@dimen/fab_image_max_size"
android:contentDescription="@string/mainmenubookmark_de"
android:src="@drawable/ic_search" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/action_map"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_weight="1"
app:fabCustomSize="@dimen/fab_size"
app:maxImageSize="@dimen/fab_image_max_size"
android:contentDescription="@string/mainmenubookmark_de"
android:src="@drawable/ic_map" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/action_calendar_timeline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_weight="1"
app:fabCustomSize="@dimen/fab_size"
app:maxImageSize="@dimen/fab_image_max_size"
android:contentDescription="@string/mainmenubookmark_de"
android:src="@drawable/ic_calendar" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/action_next_timeline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_weight="1"
app:fabCustomSize="@dimen/fab_size"
app:maxImageSize="@dimen/fab_image_max_size"
android:contentDescription="@string/mainmenubookmark_de"
android:src="@drawable/ic_next" />
</LinearLayout>
Dimens.xml:
10dp 40dp 40dp 24dp
解决方法
如果您还共享LinearLayout内容,将会很有帮助。
我还建议为此使用ConstraintLayout,它绝对简单又有趣。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。