我只能在onCreate方法中设置我的活动到全屏(在setContentView之前)?
有没有办法可以在onCreate之外设置为全屏?
由于
答案 0 :(得分:12)
可能!添加此代码。
// go full screen WindowManager.LayoutParams attrs = mActivity.getWindow().getAttributes(); attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; mActivity.getWindow().setAttributes(attrs); // go non-full screen WindowManager.LayoutParams attrs = mActivity.getWindow().getAttributes(); attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); mActivity.getWindow().setAttributes(attrs);
答案 1 :(得分:2)
答案 2 :(得分:0)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
在设置布局之前使用此选项。因为您尝试将布局设置为全屏。为什么你需要在创建方法之外? ...
答案 3 :(得分:0)
试试这个:
ec2_tag_environment_production
答案 4 :(得分:-1)
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
**requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);**
setContentView(R.layout.activity);
...
}