Reputation: 890
I use this code to hide the navigation bar. The problem is that when I go into a different activity the navigation bar pop out and hides itself again (happens in less than a second) which I don't like. How do I prevent it from poping out. Is there another way to hide it.
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
if (hasFocus) {
getWindow().getDecorView()
.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);
}
}
}
Upvotes: 1
Views: 332
Reputation: 1270
Use this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
}
Upvotes: 0
Reputation: 890
Using this in onCreate() prevent it from poping out.
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Upvotes: 2
Reputation: 230
You create one class and hide navigation bar there.And then extend this class in other two class.As a result you should use inheritence.
Upvotes: 0