android-floating-action-button icon indicating copy to clipboard operation
android-floating-action-button copied to clipboard

Space above menu cant be clicked when collapsed

Open kiaanpillay opened this issue 10 years ago • 8 comments

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

kiaanpillay avatar Aug 26 '15 17:08 kiaanpillay

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?

chRyNaN avatar Oct 08 '15 19:10 chRyNaN

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);
                }
            }
        });

chRyNaN avatar Oct 08 '15 19:10 chRyNaN

I am having the same issue

johneris avatar Dec 04 '15 09:12 johneris

Has anyone fixed this issue yet? I am facing a similar problem

Ram8948 avatar Dec 14 '15 12:12 Ram8948

@johneris @Ram8948 @kiaanpillay Could you provide a code snippet to reproduce the issue?

redwerk avatar Dec 21 '15 11:12 redwerk

https://www.youtube.com/watch?v=jjwI3ux8eU0 i uploaded this video to show the bug =) @redwerk @johneris @Ram8948 @kiaanpillay @chRyNaN

MikeSoft avatar Feb 14 '16 05:02 MikeSoft

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

3kwtloo avatar Apr 08 '16 13:04 3kwtloo

@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; }

18616505009 avatar Mar 22 '18 04:03 18616505009