Android隐藏虚拟按键

View gameView = xxxxxx; //获取当前View

//隐藏虚拟按键,并且全屏
if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
    gameView.setSystemUiVisibility(View.GONE);
} else if (Build.VERSION.SDK_INT >= 19) {
    //for new api versions.
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
    gameView.setSystemUiVisibility(uiOptions);
}

 

有时发现在AndroidManifest中设置了NoActionBar但是还是有虚拟按钮,此时就可以用上面的代码来实现。

你可能感兴趣的:(Android)