android显示与隐藏状态栏

 时间:2024-11-21 04:33:32

1、显示与隐藏状态栏的代码如下:private void fullscreen(boolean enable) { if (enab造婷用痃le) { //显示状态栏 WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; getWindow().setAttributes(lp); getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } else { //隐藏状态栏 WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setAttributes(lp); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } }

2、显示与隐藏的效果如下:

android显示与隐藏状态栏android显示与隐藏状态栏

3、横屏与竖屏切换时处理状态栏的显示与隐藏,所以需要配置屏幕切换代码。AndroidManifest.xml中activity上配置android:configChanges="orientation|keyboardHidden|screenSize"

android显示与隐藏状态栏

4、activity中override方法onConfigurationChanged@Override public void onConf足毂忍珩igurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ){//横屏 }else if( this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ){//竖屏 } }

android显示与隐藏状态栏
  • 春天7件事消春火解春毒
  • 衣服的学问,你知道吗
  • 生呛青萝卜做法
  • 连环夺宝怎么选机子?
  • 我的小家如何查看绳子的攻略
  • 热门搜索
    1982年属什么 爱就像蓝天白云晴空万里是什么歌 麾下是什么意思 烦恼的近义词是什么 猴赛雷是什么意思 死缓是什么意思 公司注册资金多少有什么区别 新华门是什么地方 username是什么意思 快递单号是什么