我有这段代码将视图设置为全屏。我希望它做的是将视图设置为全屏,方向更改为横向。我已经尝试了很多不同的解决方案,不能得到任何工作,任何帮助将不胜感激。
public class FullScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
答案 0 :(得分:1)
这是yarian建议的代码:
public class FullScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
这可能是最好的解决方案。