Skip to content Skip to sidebar Skip to footer

Android Navigation Bar On Side By Editing Aosp

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. +------------------------

Solution 1:

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 rightint 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).

<!--  navigation bar for sw600dp (small tablets) --><com.android.systemui.statusbar.phone.NavigationBarViewxmlns:android="http://schemas.android.com/apk/res/android"xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"android:layout_height="match_parent"android:layout_width="match_parent"android:background="#FF000000"
    ><FrameLayoutandroid:id="@+id/rot0"android:layout_height="match_parent"android:layout_width="match_parent"
        ><LinearLayoutandroid:layout_height="match_parent"android:layout_width="match_parent"android:orientation="vertical"android:clipChildren="false"android:clipToPadding="false"android:id="@+id/nav_buttons"android:animateLayoutChanges="true"
            ><!-- navigation controls -->
            ~
            <com.android.systemui.statusbar.policy.KeyButtonViewandroid:id="@+id/back"android:layout_width="match_parent"android:layout_height="128dp"android:src="@drawable/ic_sysbar_back"systemui:keyCode="4"android:layout_weight="0"systemui:glowBackground="@drawable/ic_sysbar_highlight"android:contentDescription="@string/accessibility_back"
                />
            ~
        </LinearLayout></FrameLayout></com.android.systemui.statusbar.phone.NavigationBarView>

Post a Comment for "Android Navigation Bar On Side By Editing Aosp"