Feroz Siddiqui Feroz Siddiqui - 2 months ago 15
Android Question

I am trying to figure out how to add dim background on click of FAB menu present in Navigational drawer

I have FAB menu in navigation drawer. I m using android.support.design.widget.FloatingActionButton button and onclick of this we show four FAB in arc shape. I have a container in Navigation drawer which keep replacing the fragment in the drawer(normal behaviour of the drawer). How can i disable the background when user click on FAB menu button. I'm a little stuck on how to complete this though.

<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>

Answer

You can not set it by setting a flag you need to add a dummy layout for the back portion of the FAB buttons and make it clickable when FAB is clicked

<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>
Comments