Space above menu cant be clicked when collapsed
I am using this component on a Map Fragment and am using my own buttons inside the menu. When the menu is collapsed I cant move the map by touching the area on the screen directly above the + icon because it thinks that is where the other items are. How can I fix this?
Loving the library! Thank you very much
Has anyone fixed this issue yet? I am facing a similar problem. When the FloatingActionsMenu is collapsed, the FloatingActionButtons onClick is being called when the screen is touched above the menu. Even though the FloatingActionButtons are not visible they still handle touch events which interferes with other touch events. This might happen due to the library setting the FloatingActionButtons visibility to invisible rather than gone during the menu's collapsed state?
A simple solution I came up with was to manually set each FloatingActionButton's visibility when the FloatingActionsMenu expanded or collapsed.
actionMenu.setOnFloatingActionsMenuUpdateListener(new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener() {
@Override
public void onMenuExpanded() {
if (fab != null) {
fab.setVisibility(View.VISIBLE);
}
}
@Override
public void onMenuCollapsed() {
if (fab != null) {
fab.setVisibility(View.GONE);
}
}
});
I am having the same issue
Has anyone fixed this issue yet? I am facing a similar problem
@johneris @Ram8948 @kiaanpillay Could you provide a code snippet to reproduce the issue?
https://www.youtube.com/watch?v=jjwI3ux8eU0 i uploaded this video to show the bug =) @redwerk @johneris @Ram8948 @kiaanpillay @chRyNaN
@chRyNaN This solution messes up the fadein-animation for me. I came up with a somewhat "cleaner" solution.
You can just extend the original class and overwrite the onTouchEvent like this:
public class FloatingActionsMenu extends com.getbase.floatingactionbutton.FloatingActionsMenu {
public FloatingActionsMenu(Context context) {
super(context);
}
public FloatingActionsMenu(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FloatingActionsMenu(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return false;
}
}
And then use your custom class in the xml like:
<com.YOUR_PATH.FloatingActionsMenu
android:id="@+id/content_main_fam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:fab_addButtonColorNormal="@color/colorAccent"
app:fab_addButtonColorPressed="@color/colorAccent"
app:fab_addButtonPlusIconColor="@color/white"
app:fab_labelStyle="@style/menu_labels_style"
app:fab_labelsPosition="left">
<com.getbase.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/activity_main_a1"
app:fab_colorNormal="@color/white"
app:fab_title="Label on the right"
app:fab_size="mini"
app:fab_colorPressed="@color/white_pressed"
app:fab_addButtonColorNormal="@color/colorAccent"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/activity_main_a2"
app:fab_colorNormal="@color/white"
app:fab_size="mini"
app:fab_title="Another one on the right"
app:fab_colorPressed="@color/white_pressed"
app:fab_addButtonColorNormal="@color/colorAccent"/>
</com.YOUR_PATH.FloatingActionsMenu>
@chRyNaN I think you are almost right,but not compeletely
I've tested the attibutes on different status of the FloatingMenu when it's collapsed: this.isExpanded()-->false,this.isActivated()-->false,this.isEnabled()-->true,this.isShown()-->true,this.isClickable()-->true when it’s enpanded: this.isExpanded()-->true,this.isActivated()-->false,this.isEnabled()-->true,this.isShown()-->true,this.isClickable()-->true
so the onTouchEvent's return value should varies according to FloatingActionsMenu.isExpanded() attributes
My solution is:
@Override public boolean onTouchEvent(MotionEvent event) { return this.isExpanded() ? true : false; }