【问题标题】:How to make Float Action Button infobox如何制作浮动操作按钮信息框
【发布时间】:2021-12-01 23:30:18
【问题描述】:

我想在浮动按钮上方添加一个信息框,如下图所示。我怎样才能做到这一点?谢谢你

Image URL CLICK

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/Theme.Fab_Bottom_app_bar"
        app:hideOnScroll="true"
        android:layout_gravity="bottom"
        app:fabCradleMargin="15dp"
        app:fabCradleRoundedCornerRadius="60dp"
        app:layout_scrollFlags="scroll|enterAlways"
        app:fabCradleVerticalOffset="10dp">

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottomNavigationView"
            android:layout_width="match_parent"
            android:theme="@style/Theme.Fab_Bottom_app_bar"
            android:background="@drawable/dropbutton"
            android:layout_height="match_parent"
            app:menu="@menu/bottom_nav_menu" />

    </com.google.android.material.bottomappbar.BottomAppBar>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/app_name"
        app:backgroundTint="#2770DC"
        app:tint="#fff"
        android:src="@drawable/icon_add"
        app:layout_anchor="@id/bottomAppBar" />

【问题讨论】:

标签: java android android-studio


【解决方案1】:

https://developer.android.com/reference/android/widget/PopupWindow

PopupWindow 应该服务于您的目的

“这个类代表一个弹出窗口,可以用来显示任意视图。弹出窗口是一个浮动容器,出现在当前活动之上。”

您可以将任何想要显示的“contentView”传递给它的构造函数,并调用“showAtLocation”方法来确定在哪里显示它。

【讨论】:

    猜你喜欢
    • 2015-06-25
    • 2016-03-28
    • 2019-06-28
    • 2019-08-05
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    • 2015-09-01
    • 1970-01-01
    相关资源
    最近更新 更多