SoFunction
Updated on 2025-03-11

Introduction to display and blocking of Android navigation bar function items

Android's navigation bar has many functions, andScreenshot, volume up, volume down, recent tasks, menu. Return to the main page, input method switch. . . . . .

Code source path: frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\

    public ButtonDispatcher getScreenshotButton() {
        return ();
    }
 
    public ButtonDispatcher getVolumeAddButton() {
        return (.volume_add);
    }
 
    public ButtonDispatcher getVolumeSubButton() {
        return (.volume_sub);
    }
 
    public ButtonDispatcher getRecentsButton() {
        return (.recent_apps);
    }
 
    public ButtonDispatcher getMenuButton() {
        return ();
    }
 
    public ButtonDispatcher getBackButton() {
        return ();
    }
 
    public ButtonDispatcher getHomeButton() {
        return ();
    }
 
    public ButtonDispatcher getImeSwitchButton() {
        return (.ime_switcher);
    }
 
    public ButtonDispatcher getAccessibilityButton() {
        return (.accessibility_button);
    }

Android completes the selection of Button icon in this category.

If you need to display/hide the corresponding function options, you need to modify it here:

private void prepareNavigationBarView() {
        ();
 
        ButtonDispatcher recentsButton = ();
        (this::onRecentsClick);
        (this::onRecentsTouch);
        (true);
        (this::onLongPressBackRecents);
 
        ButtonDispatcher backButton = ();
        (true);
        (this::onLongPressBackRecents);
 
        ButtonDispatcher homeButton = ();
        (this::onHomeTouch);
        (this::onHomeLongClick);
 
        ButtonDispatcher accessibilityButton =         ();
        (this::onAccessibilityClick);
        (this::onAccessibilityLongClick);
        updateAccessibilityServicesState(mAccessibilityManager);
 
        ButtonDispatcher screenshotButton = ();
        (this:: screenshotClick);
        (this:: screenshotTouch);
        boolean isShow=(getContext().getContentResolver(), .SCREENSHOT_BUTTON_SHOW, 1) == 1;
        if(isShow){
            ();
        }else{
            ();
        }
 
        ButtonDispatcher volumeAddButton=();
        ButtonDispatcher volumeSubButton=();
        boolean isShowVolumeButton="true".equals(("","true"));
        if(isShowVolumeButton){
            ();
            ();
        }else{
            ();
            ();
        }
        if (getContext().getResources().getConfiguration().smallestScreenWidthDp < 400) {
            ();
            ();
        }
    }

The corresponding Button can be setsetVisibility( / / ); 

When setVisibility is added and the UI interface has not been displayed, you need to pay attention to whether there is a Button required to write it into it.

frameworks\base\packages\SystemUI\res\values\

<string name="config_navBarLayout" translatable="false">left;volume_sub,back,home,recent,volume_add;right</string>

It should be noted that the order of configuration in config is the display order of UI.

If you need to use the blocked status bar and taskbar, you can put the followingstatus_bar_height The height is set to 0.

 frameworks\base\core\res\res\values\

    <!-- Height of the status bar -->
    <dimen name="status_bar_height">0dp</dimen>

This is the article about the display and blocking of Android navigation bar function items. For more related content on Android navigation bar, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!