【问题标题】:FloatingActionButton placed above another 2 widgetsFloatingActionButton 放置在另外 2 个小部件上方
【发布时间】:2015-03-05 12:51:48
【问题描述】:

使用 Android 的 Lollipop 版本 (v5.0) 并遵循 Material Design 指南,我想出了如何使用 ImageButton 标记和海拔创建 FloatingActionButton。

如何获得位于其他 2 个小部件之间(和顶部)的按钮的效果?

     widget A
---------O---------  <<<<  button is placed on top where widget a and b meet
     widget B

我被卡住了,有人有一些 XML 示例吗?

提前致谢

【问题讨论】:

  • 您是否尝试过使用RelativeLayout

标签: android android-layout android-5.0-lollipop material-design


【解决方案1】:

在 XML 中,您可以使用 FrameLayoutRelativeLayout 覆盖按钮和其他视图等小部件。 使用 FrameLayout 的快速示例:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="#88AAAA" />

<View
    android:layout_marginTop="108dp"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="#AA88AA" />

<!-- Your fab button -->
<ImageButton
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_gravity="center_horizontal"
    android:background="#ff0000"
    android:layout_marginTop="68dp" />

</FrameLayout>

结果:

:

【讨论】:

    猜你喜欢
    • 2020-09-22
    • 2023-03-27
    • 1970-01-01
    • 2011-01-18
    • 2019-01-30
    • 2021-05-09
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多