Android 去掉状态栏 去掉标题栏 沉浸式状态栏 状态栏重叠 布局重叠 SystemBarTintManager systembartint-1.0.4

来源:互联网 发布:警惕网络中的陷阱 编辑:程序博客网 时间:2024/04/27 17:40

Android 去掉状态栏 去掉标题栏  沉浸式状态栏

去掉状态栏

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
  2.         // WindowManager.LayoutParams.FLAG_FULLSCREEN);  

去掉标题栏 
[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. requestWindowFeature(Window.FEATURE_NO_TITLE);  

沉浸式状态栏

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. @Override  
  2. protected void onCreate(Bundle savedInstanceState) {  
  3.      super.onCreate(savedInstanceState);  
  4.      initWindow();  
  5. }  
[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. private SystemBarTintManager tintManager;  
  2.   
  3.     @TargetApi(19)  
  4.     private void initWindow() {  
  5.         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  
  6.             getWindow().addFlags(  
  7.                     WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);  
  8.             getWindow().addFlags(  
  9.                     WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
  10.             tintManager = new SystemBarTintManager(this);  
  11.             tintManager.setStatusBarTintColor(getColor(R.color.app_main_color));  
  12.             tintManager.setStatusBarTintEnabled(true);  
  13.         }  
  14.     }  

使用以上两个方法的最后,都要在主布局中加上,否则标题栏是白色的 或状态栏和布局重叠

布局文件上添加这俩个属性

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1.     android:fitsSystemWindows="true"  
  2.     android:clipToPadding="true"  

systembartint-1.0.4.jar下载:http://download.csdn.net/detail/menglele1314/9452638
0 0
原创粉丝点击