Android floating action button hidden behind of bottom navigation bar

后端 未结 5 2935
情书的邮戳
情书的邮戳 2021-02-20 16:41

New to android programming & struggling with right now. I\'m using android studio\'s default \"Navigation Drawer Activity\". On top of that, I\'ve added a Bottom Bar from <

5条回答
  •  情书的邮戳
    2021-02-20 17:24

    Here is a solution that works for our use case. Basically we wanted to hide bottom navigation view and the fab that belongs to it whenever the user scrolls in the screen.

    For that purpose we have decided to use the app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" that comes out of the box for BottomNavigationView. All that is left is to anchor the fab to the BottomNavigationView and use the same layout_behavior on fab, too.

    Here is an example of it:

    
    
    
        
    
        
    
        
    
        
    
    
    

    Other than that you can define your own layout_behavior for fab as explained in GitHub: BlogPosts / android-coordinatorlayout-scrolling-hide-fab-behavior.md too.

    I hope that it helps :)

提交回复
热议问题