How do I cover the navigation bar at the bottom of the system.?

enter image description hereI am trying to overlap the navigation bar at the bottom of the system using the window manager, but I am unable to do so. I am using bellow code. I've set gravity to the bottom, so it shows the layer at the bottom of my activity without overlapping the bottom nav bar.

public void onCreate(Bundle savedInstancestate)
{
  super.onCreate(savedInstancestate);
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);7

  manager = ((WindowManager)    getApplicationContext().getSystemService(Context.WINDOW_SERVICE));

  localLayoutParams = new WindowManager.LayoutParams();
  localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
  localLayoutParams.gravity = Gravity.BOTTOM;    

  localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|

       // this is to enable the notification to recieve touch events
       //WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN |
        //WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |

       // Draws over navigation bar
  WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;


  //localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
  localLayoutParams.height = (int) (50 *     getResources().getDisplayMetrics().scaledDensity);
  localLayoutParams.format = PixelFormat.TRANSPARENT;

  view = new customView(this);

  manager.addView(view, localLayoutParams);

  setContentView(R.layout.Imges);
  }
      public class customView extends ViewGroup {

              public customView(Context context) {
                super(context);
              }

            @Override
            protected void onLayout(boolean changed, int l, int t, int r, int b) {
            }

            @Override
            public boolean onInterceptTouchEvent(MotionEvent ev) {
                Log.v("customView", "------Intercepted-------");
                return true;
            }
        }         

      

Using this code, I cannot overlap the navigation, it shows the new custom view at the bottom of my activity, but cannot overlap the navigation bar with the custom view.

anyone can help me with this to overlap the navbar with a custom view.?

+3


source to share


1 answer


There are actually some solutions. You cannot stack on funds to disappear entirely as there are devices on the market without hardware buttons. However, you can arrange your layout elegantly.

For example Add this to styles.xml (v21) in the value directory :

<item name="android:windowDrawsSystemBarBackgrounds">false</item>

      

or if it doesn't work,



boolean hasMenuKey = ViewConfiguration.get(getContext()).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);

    if(!hasMenuKey && !hasBackKey) {
        // Do whatever you need to do, this device has a navigation bar
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.MATCH_PARENT
        );
        params.setMargins(0, 0, 0, 75);
        entrancelayout.setLayoutParams(params);
        entrancelayout.requestLayout();
    }

      

I had a FrameLayout, you can use it for any layout you have. SetMargins adds margin to the buttom in the example. The system bar is assumed to be present if there is no hardware return and menu buttons.

0


source







All Articles