In android O the concept of changing the icon is introduced but it is still through the 3rd party app. Custom Navigation Bar that uses WRITE_SECURE_SETTINGS
to change the icons.
In Android O you can change the display of the bar i.e Light or Dark theme.
Solution 2 can be more of a help to you.
You can create a popup window
on navigation Bar with the desired layout i.e 3 buttons back, Recent Apps and home button. In this way you can change the back button icon accordingly. Make sure the pop up window is of same height as the navigation Bar and you can then make your own functions for home and recent apps and in back function
you can close your BottomSheetDialog
and remove that popup window.
The below is the code for home key as well as recent Apps. For back button do accordingly what you want to achieve with your own icon.
For Home Button.
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
For Recent Apps.
Class serviceManagerClass = Class.forName("android.os.ServiceManager");
Method getService = serviceManagerClass.getMethod("getService", String.class);
IBinder retbinder = (IBinder) getService.invoke(serviceManagerClass, "statusbar");
Class statusBarClass = Class.forName(retbinder.getInterfaceDescriptor());
Object statusBarObject = statusBarClass.getClasses()[0].getMethod("asInterface", IBinder.class).invoke(null, new Object[] { retbinder });
Method clearAll = statusBarClass.getMethod("toggleRecentApps");
clearAll.setAccessible(true);
clearAll.invoke(statusBarObject);
For Back Button
// use your icon and function of closing the BottomSheetDialog.
For calculating the height of the navigationBar
public static int getSoftButtonsBarSizePort(Activity activity) {
// getRealMetrics is only available with API 17 and +
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int usableHeight = metrics.heightPixels;
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
int realHeight = metrics.heightPixels;
if (realHeight > usableHeight)
return realHeight - usableHeight;
else
return 0;
}
return 0;
}
you can also do it by adb
commands but make sure it can mess up your navigationBar
and you cannot get back your original navigationBar
.
I hope it helps.