【发布时间】:2014-01-25 18:17:36
【问题描述】:
当用户点击开始按钮时,我正在设置一个特定的活动全屏。
在这种情况下,showStopButton() 被调用。
运行良好。但是如果我插入
requestWindowFeature(Window.FEATURE_NO_TITLE);
然后它崩溃了,说明应该在添加内容之前调用它。
我应该如何处理它以将NO_TITLE 设置为FULL_SCREEN ?
private void showStopButton(){
// requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().findViewById(android.R.id.content).requestLayout();
// handle element visibility
((Button)findViewById(R.id.stopButton)).setEnabled(false);
((Button)findViewById(R.id.startButton)).setVisibility(View.GONE);
((Button)findViewById(R.id.stopButton)).setVisibility(View.VISIBLE);
((SeekBar)findViewById(R.id.seekBar1)).setVisibility(View.VISIBLE);
((Button)findViewById(R.id.resetButton)).setVisibility(View.GONE);
((Button)findViewById(R.id.saveButton)).setVisibility(View.GONE);
}
当重新显示开始按钮时,我有相反的过程,它运行正常 在这种情况下,我删除了全屏模式
private void showStartButton(){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().findViewById(android.R.id.content).requestLayout();
....
}
【问题讨论】:
-
你必须在“setContentView()”之前调用“requestWindowFeature”。
标签: android android-fullscreen