Android沉浸式通知栏的一个开源库SystemBarTint简单使用,android沉浸式状态栏
16lz
2021-01-23
SystemBarTint项目地址:https://github.com/jgilfelt/SystemBarTint
使用:
public class BaseActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initStatusBar(); } @Override protected void onDestroy() { super.onDestroy(); ButterKnife.unbind(this); } private void initStatusBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(true); tintManager.setStatusBarTintColor(getResources().getColor(R.color.colorPrimaryDark)); } @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); }}
更多相关文章
- Android获取移动设备的IP地址
- Android Studio : 导入项目出现 peer not authenticated 错误
- android 项目收获01
- Android 项目代码混淆
- android studio 3.6.1导入项目报错(无法下载classpath里的内容)
- Android studio升级3.0.1之后原项目签名打包出错
- Android获取物理地址(支持5.0~10.0)
- Android Studio 关联项目软链接
- eclipse android 项目报错 ERROR: Unable to open class file