Overlay on the navigation bar in Android 4

I struggle with this despite some patterns ...

I want to overlay on the Android navigation bar. I tried the following code ...

s_translucentParams = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                        | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_FULLSCREEN
                ,
                PixelFormat.TRANSLUCENT);

But of course, this fills a window that does not cover the navigation bar ... after some reading, I tried the following (from Draw raster images on top of the navigation bar in Android ) ...

w = new android.view.WindowManager.LayoutParams(-1, -1,0,-navigationBarHeight(),    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_FULLSCREEN
|WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR 
|WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, Pixel.Translucent);
f.addView(v, w);

But this does not overlap with me, despite me, changing the window size ... it just does not overlap the navigation bar :(

I want to do something like the following ...

https://play.google.com/store/apps/details?id=com.haxor&hl=en_GB

This does not appear above the navigation bar, but below (which suits my needs)

Can anyone help me? Thank you

+4
1

, Play Market, - Android KitKat (API 19). .

, Theme.Holo.NoActionBar.TranslucentDecor Theme.Holo.Light.NoActionBar.TranslucentDecor. , , fitsSystemWindows .

, windowTranslucentNavigation windowTranslucentStatus .

​​ AndroidManifest.xml :

<activity android:name="com.example.app.TranslucentActivity"
          android:theme="@android:style/Theme.Holo.NoActionBar.TranslucentDecor" />

, , - API 14 +:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

Immersive Full-Screen Mode API 19:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        decorView.setSystemUiVisibility(
                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
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);}
}

Immersive .

0

All Articles