weixin_39799290
weixin_39799290
2021-01-12 15:23

Ability to dim background when the menu is opened

On most apps that uses the FAB, the background is dimmed when the menu is opened. It would be nice to have this feature here.

该提问来源于开源项目:Clans/FloatingActionButton

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

11条回答

  • weixin_40004081 weixin_40004081 4月前

    Added to my TODO list. For now you can use OnMenuToggleListener to create such behavior by yourself.

    点赞 评论 复制链接分享
  • weixin_39799290 weixin_39799290 4月前

    Thanks! I was amazed how easy it was to implement it myself...

    点赞 评论 复制链接分享
  • weixin_39851408 weixin_39851408 4月前

    That would be great addition.

    点赞 评论 复制链接分享
  • weixin_39593498 weixin_39593498 4月前

    could you tell me how you dimmed the screen? The solution I tried (see below) didn't work.

    mFloatMenu.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {

            public void onMenuToggle(boolean opened) {
                WindowManager.LayoutParams windowManager = getActivity().getWindow().getAttributes();
                windowManager.dimAmount = 0.75f;
                getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
            }
        });
    
    点赞 评论 复制链接分享
  • weixin_39799290 weixin_39799290 4月前

    see this gist: https://gist.github.com/avrahamshukron/16513fe5622d11061d1e

    点赞 评论 复制链接分享
  • weixin_39593498 weixin_39593498 4月前

    Thanks!

    点赞 评论 复制链接分享
  • weixin_39881760 weixin_39881760 4月前

    OnMenuToggleListener work perfectly. Thanks a lot!

    点赞 评论 复制链接分享
  • weixin_40004081 weixin_40004081 4月前

    Just add the fab:menu_backgroundColor="#ccffffff" to the com.github.clans.fab.FloatingActionMenu tag. Choose the color and transparency you need.

    点赞 评论 复制链接分享
  • weixin_39713317 weixin_39713317 4月前

    But, then you have to set the width and height of the menu to match_parent or something which makes it so you can't interact with anything "under" the menu.

    点赞 评论 复制链接分享
  • weixin_39983554 weixin_39983554 4月前

    also you need to remove margins from FAB Menu. You will have a partially dimmed screen

    点赞 评论 复制链接分享
  • weixin_39920629 weixin_39920629 4月前

    JaydipRadadiya, how did you use the OnMenuToggleListener? Thanks!

    点赞 评论 复制链接分享

相关推荐