library/src/main/java/com/oguzdev/circularfloatingactionmenu/library/FloatingActionMenu.java
public void open(boolean animated) {

        // Get the center of the action view from the following function for efficiency
        // populate destination x,y coordinates of Items
        Point center = calculateItemPositions();

        WindowManager.LayoutParams overlayParams = null;

        if(systemOverlay) {
            // If this is a system overlay menu, use the overlay container and place it behind
            // the main action button so that all the views will be added into it.
            attachOverlayContainer();

            overlayParams = (WindowManager.LayoutParams) overlayContainer.getLayoutParams();
        }

        if(animated && animationHandler != null) {
            // If animations are enabled and we have a MenuAnimationHandler, let it do the heavy work
            if(animationHandler.isAnimating()) {
                // Do not proceed if there is an animation currently going on.
                return;
            }

            for (int i = 0; i < subActionItems.size(); i++) {
                // It is required that these Item views are not currently added to any parent
                // Because they are supposed to be added to the Activity content view,
                // just before the animation starts
                if (subActionItems.get(i).view.getParent() != null) {
                    throw new RuntimeException("All of the sub action items have to be independent from a parent.");
                }

                // Initially, place all items right at the center of the main action view
                // Because they are supposed to start animating from that point.
                final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(subActionItems.get(i).width, subActionItems.get(i).height, Gravity.TOP | Gravity.LEFT);

                if(systemOverlay) {
                    params.setMargins(center.x - overlayParams.x - subActionItems.get(i).width / 2, center.y - overlayParams.y - subActionItems.get(i).height / 2, 0, 0);
                }
                else {
                    params.setMargins(center.x - subActionItems.get(i).width / 2, center.y - subActionItems.get(i).height / 2, 0, 0);
                }
                addViewToCurrentContainer(subActionItems.get(i).view, params);
            }
            // Tell the current MenuAnimationHandler to animate from the center
            animationHandler.animateMenuOpening(center);
        }
        else {
            // If animations are disabled, just place each of the items to their calculated destination positions.
            for (int i = 0; i < subActionItems.size(); i++) {
                // This is currently done by giving them large margins

                final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(subActionItems.get(i).width, subActionItems.get(i).height, Gravity.TOP | Gravity.LEFT);
                if(systemOverlay) {
                    params.setMargins(subActionItems.get(i).x - overlayParams.x, subActionItems.get(i).y - overlayParams.y, 0, 0);
                    subActionItems.get(i).view.setLayoutParams(params);
                }
                else {
                    params.setMargins(subActionItems.get(i).x, subActionItems.get(i).y, 0, 0);
                    subActionItems.get(i).view.setLayoutParams(params);
                    // Because they are placed into the main content view of the Activity,
                    // which is itself a FrameLayout
                }
                addViewToCurrentContainer(subActionItems.get(i).view, params);
            }
        }
        // do not forget to specify that the menu is open.
        open = true;

        if(stateChangeListener != null) {
            stateChangeListener.onMenuOpened(this);
        }

    }
public void open(boolean animated) {

        // Get the center of the action view from the following function for efficiency
        // populate destination x,y coordinates of Items
        Point center = calculateItemPositions();

        WindowManager.LayoutParams overlayParams = null;

        if(systemOverlay) {
            // If this is a system overlay menu, use the overlay container and place it behind
            // the main action button so that all the views will be added into it.
            attachOverlayContainer();

            overlayParams = (WindowManager.LayoutParams) overlayContainer.getLayoutParams();
        }

        if(animated && animationHandler != null) {
            // If animations are enabled and we have a MenuAnimationHandler, let it do the heavy work
            if(animationHandler.isAnimating()) {
                // Do not proceed if there is an animation currently going on.
                return;
            }

            for (int i = 0; i < subActionItems.size(); i++) {
                // It is required that these Item views are not currently added to any parent
                // Because they are supposed to be added to the Activity content view,
                // just before the animation starts
                if (subActionItems.get(i).view.getParent() != null) {
                    throw new RuntimeException("All of the sub action items have to be independent from a parent.");
                }

                // Initially, place all items right at the center of the main action view
                // Because they are supposed to start animating from that point.
                final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(subActionItems.get(i).width, subActionItems.get(i).height, Gravity.TOP | Gravity.LEFT);

                if(systemOverlay) {
                    params.setMargins(center.x - overlayParams.x - subActionItems.get(i).width / 2, center.y - overlayParams.y - subActionItems.get(i).height / 2, 0, 0);
                }
                else {
                    params.setMargins(center.x - subActionItems.get(i).width / 2, center.y - subActionItems.get(i).height / 2, 0, 0);
                }
                addViewToCurrentContainer(subActionItems.get(i).view, params);
            }
            // Tell the current MenuAnimationHandler to animate from the center
            animationHandler.animateMenuOpening(center);
        }
        else {
            // If animations are disabled, just place each of the items to their calculated destination positions.
            for (int i = 0; i < subActionItems.size(); i++) {
                // This is currently done by giving them large margins

                final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(subActionItems.get(i).width, subActionItems.get(i).height, Gravity.TOP | Gravity.LEFT);
                if(systemOverlay) {
                    params.setMargins(subActionItems.get(i).x - overlayParams.x, subActionItems.get(i).y - overlayParams.y, 0, 0);
                    subActionItems.get(i).view.setLayoutParams(params);
                }
                else {
                    params.setMargins(subActionItems.get(i).x, subActionItems.get(i).y, 0, 0);
                    subActionItems.get(i).view.setLayoutParams(params);
                    // Because they are placed into the main content view of the Activity,
                    // which is itself a FrameLayout
                }
                addViewToCurrentContainer(subActionItems.get(i).view, params);
            }
        }
        // do not forget to specify that the menu is open.
        open = true;

        if(stateChangeListener != null) {
            stateChangeListener.onMenuOpened(this);
        }

    }
public void open ( boolean animated ) { // Get the center of the action view from the following function for efficiency // populate destination x,y coordinates of Items Point center = calculateItemPositions ( ) ; WindowManager . LayoutParams overlayParams = null ; if ( systemOverlay ) { // If this is a system overlay menu, use the overlay container and place it behind // the main action button so that all the views will be added into it. attachOverlayContainer ( ) ; overlayParams = ( WindowManager . LayoutParams ) overlayContainer . getLayoutParams ( ) ; } if ( animated && animationHandler != null ) { // If animations are enabled and we have a MenuAnimationHandler, let it do the heavy work if ( animationHandler . isAnimating ( ) ) { // Do not proceed if there is an animation currently going on. return ; } for ( int i = 0 ; i < subActionItems . size ( ) ; i ++ ) { // It is required that these Item views are not currently added to any parent // Because they are supposed to be added to the Activity content view, // just before the animation starts if ( subActionItems . get ( i ) . view . getParent ( ) != null ) { throw new RuntimeException ( "All of the sub action items have to be independent from a parent." ) ; } // Initially, place all items right at the center of the main action view // Because they are supposed to start animating from that point. final FrameLayout . LayoutParams params = new FrameLayout . LayoutParams ( subActionItems . get ( i ) . width , subActionItems . get ( i ) . height , Gravity . TOP | Gravity . LEFT ) ; if ( systemOverlay ) { params . setMargins ( center . x - overlayParams . x - subActionItems . get ( i ) . width / 2 , center . y - overlayParams . y - subActionItems . get ( i ) . height / 2 , 0 , 0 ) ; } else { params . setMargins ( center . x - subActionItems . get ( i ) . width / 2 , center . y - subActionItems . get ( i ) . height / 2 , 0 , 0 ) ; } addViewToCurrentContainer ( subActionItems . get ( i ) . view , params ) ; } // Tell the current MenuAnimationHandler to animate from the center animationHandler . animateMenuOpening ( center ) ; } else { // If animations are disabled, just place each of the items to their calculated destination positions. for ( int i = 0 ; i < subActionItems . size ( ) ; i ++ ) { // This is currently done by giving them large margins final FrameLayout . LayoutParams params = new FrameLayout . LayoutParams ( subActionItems . get ( i ) . width , subActionItems . get ( i ) . height , Gravity . TOP | Gravity . LEFT ) ; if ( systemOverlay ) { params . setMargins ( subActionItems . get ( i ) . x - overlayParams . x , subActionItems . get ( i ) . y - overlayParams . y , 0 , 0 ) ; subActionItems . get ( i ) . view . setLayoutParams ( params ) ; } else { params . setMargins ( subActionItems . get ( i ) . x , subActionItems . get ( i ) . y , 0 , 0 ) ; subActionItems . get ( i ) . view . setLayoutParams ( params ) ; // Because they are placed into the main content view of the Activity, // which is itself a FrameLayout } addViewToCurrentContainer ( subActionItems . get ( i ) . view , params ) ; } } // do not forget to specify that the menu is open. open = true ; if ( stateChangeListener != null ) { stateChangeListener . onMenuOpened ( this ) ; } }
Simply opens the menu by doing necessary calculations.
@param animated if true, this action is executed by the current {@link MenuAnimationHandler}
Simply opens the menu by doing necessary calculations .