Android 实现沉浸式(使用SystemBarTint第三方)
来源:互联网 发布:快速选择中值算法 编辑:程序博客网 时间:2024/06/03 08:58
1.导入Jar https://github.com/jgilfelt/SystemBarTint
2.在BaseActivity中配置
2.在BaseActivity中配置
protected int mColorId=R.color.statusbar_bg;//状态栏的默认背景色private SystemBarTintManager tintManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); initStateBar(); } /** * 初始化沉浸式 */ private void initStateBar() { setColorId(); if (isNeedLoadStatusBar()) { loadStateBar(); } }private void loadStateBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } tintManager = new SystemBarTintManager(this); // 激活状态栏设置 tintManager.setStatusBarTintEnabled(true); // 激活导航栏设置 tintManager.setNavigationBarTintEnabled(true); // 设置一个状态栏颜色 tintManager.setStatusBarTintResource(getColorId()); }
@TargetApi(19) private void setTranslucentStatus(boolean on) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); } /** * 如果子类使用非默认的StatusBar,就重写此方法,传入布局的id */ protected void setColorId() { //this.mColorId=R.color.XXX;子类重写方式 } protected int getColorId() { return mColorId; } /** * 子类是否需要实现沉浸式,默认需要 * * @return */ protected boolean isNeedLoadStatusBar() { return true; }
3.在布局文件根标签加入下面两行代码
android:clipToPadding="false"android:fitsSystemWindows="true"
阅读全文
0 0
- Android 实现沉浸式(使用SystemBarTint第三方)
- Android使用systembartint库实现沉浸式状态栏效果
- 很好的一个沉浸式效果 (使用第三方 SystemBarTint)
- 沉浸式状态栏实现-SystemBarTint
- SystemBarTint实现沉浸式状态栏
- Android沉浸式状态栏SystemBarTint
- Android 实现沉浸式状态栏效果(systembartint库)
- Android沉浸式通知栏的一个开源库SystemBarTint简单使用,android沉浸式状态栏
- 借助SystemBarTint实现透明标题栏(沉浸式)
- SystemBarTint实现沉浸模式
- 个人总结:使用第三方实现沉浸式状态栏
- Android沉浸式状态栏SystemBarTint的使用方法
- Android沉浸式状态栏SystemBarTint的使用方法
- Android沉浸式状态栏SystemBarTint的使用方法
- Android沉浸式状态栏SystemBarTint的使用方法
- SystemBarTint沉浸式状态栏
- 关于Android沉浸式通知栏的一个开源库SystemBarTint简单使用
- 关于Android沉浸式通知栏的一个开源库SystemBarTint简单使用
- android官方侧滑菜单DrawerLayout详解
- 航院5538:House Building
- esp8266烧写MicorPython
- android 使用httpURLConnection post方式访问接口的简单工具包
- Linux目录与文件的权限意义
- Android 实现沉浸式(使用SystemBarTint第三方)
- centos7编译安装php7我遇到的错误
- ES6之Iterator和for...of
- redis的list操作
- ipcs和ipcrm用法简介
- tensorflow for循环 while循环 实例
- 深入分析MySQL 的备份和恢复机制
- 第七周项目3-负数把正数赶出队列
- androidstudio 跳转页面时无法显示