SoFunction
Updated on 2025-03-11

How to hide virtual buttons on the bottom of your phone on Android

Today's Android phones have many virtual buttons on the bottom, such as Huawei, nexus, Meizu, etc., which generally have no impact on the APP, but sometimes it must be forced to hide.

For example: when playing games, when taking pictures.

Next, add a few methods and it will be OK. The code is as follows:

/**
  * Hide virtual buttons and set them to full screen
  */ 
 protected void hideBottomUIMenu(){ 
  if (.SDK_INT > 11 && .SDK_INT < 19) { // lower api 
   View v = ().getDecorView(); 
   (); 
  } else if (.SDK_INT >= 19) { 
   //for new api versions. 
   View decorView = getWindow().getDecorView(); 
   int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
     | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
     | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
     | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar 
      | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar 
     | View.SYSTEM_UI_FLAG_IMMERSIVE; 
   (uiOptions); 
   getWindow().addFlags(.FLAG_TRANSLUCENT_NAVIGATION); 
  } 
} 

Decompile (can be found in the system/framework/ folder in your phone), open res/values/

/**
  * Check if there is a virtual keybar
  * @param context
  * @return
  */ 
  public static boolean hasNavBar(Context context) { 
   Resources res = (); 
 //This method must be written correctly, and the internal method should be called through reflection.   int resourceId = ("config_showNavigationBar", "bool", "android"); 
   if (resourceId != 0) { 
    boolean hasNav = (resourceId); 
    // check override flag 
    String sNavBarOverride = getNavBarOverride(); 
    if ("1".equals(sNavBarOverride)) { 
     hasNav = false; 
    } else if ("0".equals(sNavBarOverride)) { 
     hasNav = true; 
    } 
    return hasNav; 
   } else { // fallback 
    return !(context).hasPermanentMenuKey(); 
   } 
  } 

  /**
    * Determine whether the virtual keybar is rewrite
    * @return
    */ 
  private static String getNavBarOverride() { 
   String sNavBarOverride = null; 
   if (.SDK_INT >= Build.VERSION_CODES.KITKAT) { 
    try { 
     Class c = (""); 
     Method m = ("get", ); 
     (true); 
     sNavBarOverride = (String) (null, ""); 
    } catch (Throwable e) { 
   } 
  } 
  return sNavBarOverride; 
} 

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.