lusccc / SpringFloatingActionMenu

Apache License 2.0
368 stars 71 forks source link

Disable moving fab animation #21

Open pishguy opened 8 years ago

pishguy commented 8 years ago

Hi @tiancaiCC, @brucetoo how can i disable moving fab button? i dont like that :)

pishguy commented 8 years ago

how can i disable that?

brucetoo commented 8 years ago

try it yourself,ask before you try.

pishguy commented 8 years ago

as far as i know you said you are accepted to fix that, :)

brucetoo commented 8 years ago

what you said is not the bug..but the feature you want,so try to customize by yourself

pishguy commented 8 years ago

could you help me whats this feature? is that mEnableFollowAnimation ?? after set to false not change that

lusccc commented 8 years ago

I have updated the library, you can use enableFollowAnimation(false) method in SpringFloatingActionMenu.Builder, hope that can help you. Also thank @brucetoo ~

pishguy commented 8 years ago

@brucetoo yes i see, but when i try to use that i get error:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference
                                                                     at com.pishguy.androidapplication.cafemaku.Libraries.SpringFloatingActionMenu.SpringFloatingActionMenu.onLayout(SpringFloatingActionMenu.java:237)
                                                                     at android.view.View.layout(View.java:16722)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                     at android.view.View.layout(View.java:16722)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                     at android.view.View.layout(View.java:16722)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                     at android.view.View.layout(View.java:16722)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
                                                                     at android.view.View.layout(View.java:16722)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
                                                                     at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2685)
                                                                     at android.view.View.layout(View.java:16722)
                                                                     at android.view.ViewGroup.layout(ViewGroup.java:5438)
                                                                     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2175)
                                                                     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1935)
                                                                     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1111)
                                                                     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6017)
                                                                     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                                     at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                     at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                                     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                     at android.os.Looper.loop(Looper.java:234)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5526)
                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
com.pishguy.androidapplication.cafemaku E/CustomActivityOnCrash: App has crashed, executing CustomActivityOnCrash's UncaughtExceptionHandler
                                                                 java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference

Sample:

    springFloatingActionMenu = new SpringFloatingActionMenu.Builder(this)
            .fab(fab)
            .addMenuItem(R.color.chat, R.mipmap.ic_launcher, Utils.getString(R.string.app_name), R.color.white, this)
            .addMenuItem(R.color.quote, R.mipmap.ic_launcher, Utils.getString(R.string.app_name), R.color.white, this)
            .addMenuItem(R.color.audio, R.mipmap.ic_launcher, Utils.getString(R.string.app_name), R.color.white, this)
            .addMenuItem(R.color.audio, R.mipmap.ic_launcher, Utils.getString(R.string.app_name), R.color.white, this)
            .addMenuItem(R.color.md_amber_400, R.mipmap.ic_launcher, Utils.getString(R.string.app_name), R.color.white, this)
            .addMenuItem(R.color.audio, R.drawable.ic_done_white_24dp, Utils.getString(R.string.app_name), R.color.white, this
            .animationType(SpringFloatingActionMenu.ANIMATION_TYPE_TUMBLR)
            .revealColor(R.color.colorPrimary)
            .enableFollowAnimation(false)
            .gravity(Gravity.RIGHT | Gravity.BOTTOM)
            .onMenuActionListner(new OnMenuActionListener() {
                @Override
                public void onMenuOpen() {
                    springMenuVisibleState = true;
                }
                @Override
                public void onMenuClose() {
                    springMenuVisibleState = false;
                }
            }).build();
lusccc commented 8 years ago
 for (ImageButton circle : mFollowCircles) {
            int x = fabCenterX - circle.getWidth() / 2;
            int y = fabCenterY - circle.getHeight() / 2;
            circle.layout(x, y, x + circle.getMeasuredWidth(), y + circle.getMeasuredHeight());
        }

obviously mFollowCircles is null , you can add if (mFollowCircles != null) to avoid it , sorry it's my mistake, but you can solve this problem by yourself.

pishguy commented 8 years ago

@brucetoo thanks, i have to add that more that your refer to resolve this problem

hwyhard commented 7 years ago

@tiancaiCC 你好,首先非常感谢你写了这么棒的一个库,我也遇到了同样的问题。我是一个新手,我研究了很久源代码还是没有搞懂应该怎么去改。mFollowCircles的这个循环在onLayout方法中,我应该继承你的类然后重写这个方法吗?请你指点一下或者给一点思路吧,谢谢!因为配合RecyclrView时Fab下移后面 的也就是菜单里面的按钮会显示出来,我想取消掉他们,是不是改好了之后用enableFollowingAnimotion()可以实现?我不是伸手党,实在没有思路,如果你能指点下就太好了。 @MahdiPishguy Hi, i meet the same question. And I have research for a lot of time and till have no idea. Could you please tell me how you fix that problem. I am just a beginner and i will appreciate if you can give me some suggestions.

pishguy commented 7 years ago

@hwyhard moving floating action button items?

hwyhard commented 7 years ago

@MahdiPishguyThanks for your reply! Actually i attach fab to my recyclerview and i find that when list scrolls and fab go to the bottom, that's what i want. But the button items in the menu are still show on the screen which should be disappeared. I don't need the moving flating action button items function and animotion. So I try enableFollowAnimotion(false) and meet the same question. I read the source code and don't know how to fix the problem.Could you please tell me how you fix it?