android - 我想弄清楚如何在单击抽屉导航中的 FAB 菜单时添加暗淡的背景

标签 android navigation-drawer floating-action-button

我在抽屉导航中有 FAB 菜单。我正在使用 android.support.design.widget.FloatingActionButton 按钮和点击按钮,我们以弧形显示四个 FAB。我在抽屉导航中有一个容器,它不断替换抽屉中的 fragment (抽屉的正常行为)。当用户单击 FAB 菜单按钮时,如何禁用背景。不过,我对如何完成这个有点困惑。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:gravity="center"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


 <FrameLayout
        android:layout_below="@id/toolbar"
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        >
        <RelativeLayout
            android:id="@+id/obstructor"
            android:visibility="invisible"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:alpha="1000"
            android:background="@android:color/black">
</RelativeLayout>

        <android.support.design.widget.FloatingActionButton
        android:id="@+id/home"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignBottom="@id/frame_container"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="6dp"
        app:fabSize="normal"
        android:src="@drawable/ic_action_navigation_close_inverted"
        app:backgroundTint="@android:color/holo_red_dark"
        app:rippleColor="#F06292">
</android.support.design.widget.FloatingActionButton>
    </FrameLayout>
   </RelativeLayout>

最佳答案

在你的布局中添加这个,

            android:translationZ="2dp"

它会起作用

<RelativeLayout
            android:id="@+id/obstructor"
            android:visibility="invisible"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:alpha="0.75"
            android:background="#00000000"
            android:translationZ="2dp"

            />

关于android - 我想弄清楚如何在单击抽屉导航中的 FAB 菜单时添加暗淡的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38850471/

相关文章:

android - Material Design 扩展 float 操作按钮没有涟漪效应

Android,选择图像

android - make snod 没有工作, 'out/target/product/generic/root/file_contexts' 需要这样的警告 :No rule to make target 'snod' ,

java - Activity 内的 Android 上下文可以是静态的吗?

android - 我在使用 DrawerLayout 时遇到一些问题

java - DrawerLayout 后退箭头功能

php - 远程数据库的记录为空

android - 为 NavigationDrawer 项目设置边距

flutter - FloatingActionButton 在列表的最后一项上

android - float 操作按钮(fab)行为在隐藏后停止 onNestedScroll