Reputation: 51
I've got a promblem with Android app.
I use this code to hide navigation bar.
public class Initer {
public static void fullScreen(Window window) {
if (Build.VERSION.SDK_INT >= 19) {
View decor = window.getDecorView();
fullScreen(decor);
} else {
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
public static void fullScreen(View decor) {
if (Build.VERSION.SDK_INT >= 19) {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
}
But when I show PopupWindow
or Dialog
up, navigation bar will come up again.
I tried do this
PopupWindow popupWindow =new PopupWindow(getWindow().getContext());
View popupWindowView = LayoutInflater.from(getWindow().getContext()).
inflate(R.layout.dialog_interval_insert, null);
Initer.fullScreen(popupWindowView);
...
popupWindow.showAsDropDown(button_start);
to hide navigation bar when PopupWindow
showing up. But it doesn't work. When I call the PopupWindow
, the navigation bar will show up then hide again. And when I dismiss()
it, navigation bar will be there.
How can I hide navigation bar permanently in Whole application?
Upvotes: 0
Views: 1738
Reputation: 191
you can use this code
public void FullScreen_Activity(Activity activity) {
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
and change StatusBar Color with
public void setStatusBarColor(Activity activity, int RecColor) {
if (isApi21()) {
Window window = activity.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// finally change the color
window.setStatusBarColor(ContextCompat.getColor(activity, RecColor));
}
}
and how to use FullScreen_Activity method
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getMethod().FullScreen_Activity(this);
setContentView(R.layout.activity_splash);
}
}
Upvotes: 1