扩展FAB菜单时淡出整个屏幕

Met*_*arf 1 android screen floating-action-button

我有一个浮动操作按钮菜单,在点击时可以展开菜单项.如何实现与下面照片中显示的相同的行为?请帮忙. 在此输入图像描述

我目前有以下布局语法:

<RelativeLayout
.
. 
/>

    <View
        android:id="@+id/detailsDimView"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="#F2FFFFFF"
         android:visibility="gone" />

     <!--main content-->
     <LinearLayout
     .
     .
     />
     <FloatingActionsMenu
     .
     .>
            <!--Floating actions buttons-->
     </FloatingActionsMenu

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

但主要内容并没有消退.什么似乎是问题?

edd*_*rdo 9

试试这个

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<!-- Main Content here -- >


<!-- View to show the alpha background -->
<View
    android:id="@+id/shadowView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F2FFFFFF"
    android:visibility="gone" />

<FloatingActionsMenu
    android:id="@+id/floating_menu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/content"
    android:layout_marginBottom="16dp"
    fab:fab_addButtonColorNormal="@color/accent"
    fab:fab_addButtonColorPressed="@color/accent"
    fab:fab_labelStyle="@style/menu_labels_style"
    fab:fab_labelsPosition="left">

    <!-- Floatingbuttons -->

   </FloatingActionsMenu>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

在您的活动中,您有一个用于展开的监听器并关闭浮动菜单.你应该在那里设置shadowView的可见性.

伪代码监听器

 @Override
public void onMenuExpanded() {
    mShadowView.setVisibility(View.VISIBLE);
}

@Override
public void onMenuCollapsed() {
    mShadowView.setVisibility(View.GONE);
}
Run Code Online (Sandbox Code Playgroud)

如果要在操作栏/工具栏上方设置shadowView

试试这个

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

 <android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/primary" />


<!-- Main Content here -- >

<!-- View to show the alpha background -->
<View
    android:id="@+id/shadowView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#F2FFFFFF"
    android:visibility="gone" />

<FloatingActionsMenu
    android:id="@+id/floating_menu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/content"
    android:layout_marginBottom="16dp"
    fab:fab_addButtonColorNormal="@color/accent"
    fab:fab_addButtonColorPressed="@color/accent"
    fab:fab_labelStyle="@style/menu_labels_style"
    fab:fab_labelsPosition="left">

    <!-- Floatingbuttons -->

   </FloatingActionsMenu>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)