BottomNavigationBar underneath NavBar

后端 未结 3 423

The Goal:

1) Make the status bar transparent - Done

2) Make the BottomNavigationView and the Navbar

3条回答
  •  感情败类
    2020-12-11 02:41

    How would I make the TOP of the layout go underneath the statusbar?

    Add this to root layout of each activity you need:

    android:fitsSystemWindows="true"
    

    BottomNavigationView falls underneath the NavBar

    I don't know if you can find a way to handle this as long as you keep using FLAG_LAYOUT_NO_LIMITS. If you still want to use it, you may try to check if device has a NavigationBar and calculate its height which you can give to BottomNavigationView as a bottom margin.

    To do that you can find some useful methods in this SO answer. Add another method like:

    public void setMargin(int height){
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mBottomNavigationView.getLayoutParams();
        params.bottomMargin = height;
    }
    

    And in onCreate(), get the height of the NavigationBar if it exists and setMargin of BottomNavigationView:

    int bottomNavHeight = getNavigationBarSize(this).y;
    if( bottomNavHeight > 0){
             setMargin(bottomNavHeight);
    }
    

    Result will be like:

提交回复
热议问题