android 4.X版本中,如何去除下方的虚拟按键

2025-04-05 05:09:06
推荐回答(1个)
回答1:

Android 4.0 隐藏虚拟按键(导航栏)的代码:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class HideTestActivity extends Activity implements OnClickListener{
View main ;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
main = getLayoutInflater().from(this).inflate(R.layout.main, null);
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
main.setOnClickListener(this);
setContentView(main);
}

@Override
public void onClick(View v) {
int i = main.getSystemUiVisibility();
if (i == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) {
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
} else if (i == View.SYSTEM_UI_FLAG_VISIBLE){
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
} else if (i == View.SYSTEM_UI_FLAG_LOW_PROFILE) {
main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
}
}