How to hide virtual buttons?
In class AndroidLauncher add these lines of code:
import android.os.Build;
import android.annotation.TargetApi;
...
// In KITKAT (4.4) and next releases, hide the virtual buttons
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
hideVirtualButtons();
}
...
@TargetApi(19)
private void hideVirtualButtons() {
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_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// In KITKAT (4.4) and next releases, hide the virtual buttons
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
hideVirtualButtons();
}
}
}
No comments:
Post a Comment