0
votes

I want to make a fully transparent status bar and navigation bar like Google Play did. When I use window settings to achieve it, the keyboard covers EditText.

When this code used EditText covered by Keyboard Input:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                      WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Also this code doesn't make it fully transparent, it just makes it translucent

getWindow().setNavigationBarColor(Color.TRANSPARENT)

or this

<item name="android:navigationBarColor">@android:color/transparent</item>

I need a window like this:

enter image description here

2
Why not make the navigationBarColor same as the rest of the layout? For example, <item name="android:navigationBarColor">@color/colorPrimary</item> colorPrimary or the color that matches your main layout.Prince Ali
I have already tried that, it is not enough. For example; when i interact with other UI components like drawer layout, color of navigation bar can not integrate to layout's background. It is useful but need more than it.Snefru Clone
Idk what you mean by integrating to background. When the drawer is open, the nav bar and status bar will be dimmed. I beleive that's meant to be like that.Prince Ali

2 Answers

0
votes

What you need is something like this:

class Utils {

     static void enableInmersiveMode(Activity act, boolean drawBehindNavBar) {
          View rootView = act.getWindow().getDecorView().getRootView();
          int uiFlags = rootView.getSystemUiVisibility();
          int flags =0;
          if(drawBehindNavBar) { flags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; }
          flags = flags | uiFlags | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEEN;
          rootView.setSystemUiVisibility(flags);
     }
}

And in your onCreate of your activity:


@Override
void onCreate(Bundle b) {
    Utils.enableInmersiveMode(this, true);
    super.onCreate(b);
    // setContentView and the rest of your code here...
}

Take in mind that afterwards views will go behind the system UI and you'll need to dynamically add padding to the first and last Views so the user can interact with them.

0
votes

Hopefully, you can try this in your-main-path/res/values/styles.xml This is for transparent Status Bar and Navigation Bar in any android devices.

<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>

One more thing if you want to try transparency and float the to the bar you can use this but the background of Navigation Bar will reduce 50% of transparency.

<item name="android:windowTranslucentNavigation">true</item>

When you want to unset the TranslucentNavigation float, this one can fit the screen between Status Bar and Navigation Bar

<item name="android:fitsSystemWindows">true</item>