4

I am struggling with this despite going through some samples...

I want to overlay over the android navigation bar - I have 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, that fills a window which does not cover the navigation bar... after doing some reading, I tried the following (from Draw bitmaps 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 overlay for me despite me altering the window size ... it just doesn't overlap the navigation bar :(

I want to make something like the following...

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

This does not display above the navigation bar, but below it (which is fine for my needs)

Can anyone help me? thanks.

Community
  • 1
  • 1

1 Answers1

0

What you see on screenshots at your Play Market link is Android KitKat's (API 19) Translucent Decor.

You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.

If you're creating a custom theme, set one of these themes as the parent theme or include the windowTranslucentNavigation and windowTranslucentStatus style properties in your theme.

Your translucent Activity should be declared in AndroidManifest.xml like:

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

Other way you might want to go is just hiding Navigation Bar with 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);

Or you might want to use Immersive Full-screen Mode with 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);}
}

Take a look at Using Immersive Full-Screen Mode and Hiding the Navigation Bar for more detailed information.

Taras
  • 105
  • 1
  • 7
  • This is a perfect reply and covers many ways to sort the problem depending on version; thanks a lot for this!! –  Aug 19 '14 at 18:17