Android : Implementing FAB menu with disabled background

on Sunday, March 8, 2015


I'm trying to implement a FAB menu like the one Googles Inbox app uses. The problem is that when i add a background (with an onClickListener) to overlay the screen all other onClickListeners are cleared.


Fragment layout (in main layout are some onClickListeners implemented):



<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp">

<!-- main layout -->

</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fab_back">

<FrameLayout <!-- fabs for menu -->
android:id="@+id/rec_multi_fabs"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginRight="5dp"
android:orientation="vertical">
</FrameLayout>

<include layout="@layout/fab"></include>
</RelativeLayout>


I then use a normal onClickListener to switch between showing only the Fab or the Fab menu with background:



fabBack = (RelativeLayout) mRootView.findViewById(R.id.fab_back);
fabBack.setBackground(transparentDrawable);
fabBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stateChange(); //triggers the fab and background visibility
}
});


Now i really don't know how to have a clickListener for the background (as in Inbox) but still saving all underlying Listeners. I hope someone knows a solution for this and thanks in advance!


0 comments:

Post a Comment