Android Navigation Bar on side by editing AOSP

前端 未结 1 1774
暖寄归人
暖寄归人 2021-02-09 23:57

I want to put the Navigation Bar (has system soft keys like back, home and menu. not Navigation Drawer!) on the (right) side, like below, by editing AOSP.

+-----         


        
1条回答
  •  庸人自扰
    2021-02-10 00:57

    Navigation Bar can be placed on right side by editing PhoneWindowManager.java and navigation_bar.xml.

    Set mNavigationBarOnBottom to false in PhoneWindowManager then the following code will run.

    // PhoneWindowManager.java
    // if mNavigationBarOnBottom = false
    // Landscape screen; nav bar goes to the right
    int left = displayWidth - mNavigationBarWidthForRotation[displayRotation];
    mTmpNavigationFrame.set(left, 0, displayWidth, displayHeight);
    mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
    if (navVisible) {
        mNavigationBar.showLw(true);
        mDockRight = mTmpNavigationFrame.left;
        mRestrictedScreenWidth = mDockRight - mDockLeft;
    } else {
        // We currently want to hide the navigation UI.
        mNavigationBar.hideLw(true);
    }
    if (navVisible && !mNavigationBar.isAnimatingLw()) {
        // If the nav bar is currently requested to be visible,
        // and not in the process of animating on or off, then
        // we can tell the app that it is covered by it.
        mSystemRight = mTmpNavigationFrame.left;
    }
    

    This creates the frame for navigation bar on right instead of bottom, now layout needs to be edited to display system buttons vertically(navigation_bar.xml).

    
        
            
                
                
                ~
                
                ~
            
        
    
    

    0 讨论(0)
提交回复
热议问题