我在导航抽屉中有FAB菜单。我使用的是android.support.design.widget.FloatingActionButton按钮,此按钮的onclick显示了四个弧形的FAB。我在导航抽屉中有一个容器,该容器会不断替换抽屉中的片段(抽屉的正常行为)。当用户单击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>
最佳答案
您不能通过设置标志来设置它,该标志需要为FAB按钮的背面添加虚拟布局并在单击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>
<LinearLayout
android:id="@+id/llRoot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:orientation="vertical" />
<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>