android 4.4状态栏沉浸
2015-09-12 19:05
393 查看
找了半天代码发现好多帖子好乱
最后在github发现开源库:SystemBarTint
直接使用。即可
You must first enable translucency in your Activity - either by using or inheriting from one of the various
by setting the
attributes to
to your Activity window in code.
If translucency is not enabled or your app is running on a platform version earlier than API 19, the system UI will appear as normal. You should not enable tinting when using fullscreen or immersive window modes. You can safely use this library on Android versions
back to API 10.
To enable the tint:
To provide custom tint color values or drawables:
Developers should not need to concern themselves with the size or positioning of the system UI. Use
conjunction with
padded within the system UI bounds. However, certain elements like the
you to determine the pixel insets for the system bars in order to provide the appropriate layout effect.
Use the
access those inset values:
Download and include the JAR in
your project, or add the dependency in your
最后在github发现开源库:SystemBarTint
直接使用。即可
Usage
You must first enable translucency in your Activity - either by using or inheriting from one of the various *.TranslucentDecorthemes,
by setting the
android:windowTranslucentNavigationor
android:windowTranslucentStatustheme
attributes to
trueor by applying the
FLAG_TRANSLUCENT_N***IGATIONor
FLAG_TRANSLUCENT_STATUSflags
to your Activity window in code.
If translucency is not enabled or your app is running on a platform version earlier than API 19, the system UI will appear as normal. You should not enable tinting when using fullscreen or immersive window modes. You can safely use this library on Android versions
back to API 10.
To enable the tint:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // create our manager instance after the content view is set SystemBarTintManager tintManager = new SystemBarTintManager(this); // enable status bar tint tintManager.setStatusBarTintEnabled(true); // enable navigation bar tint tintManager.setNavigationBarTintEnabled(true); }
To provide custom tint color values or drawables:
// set a custom tint color for all system bars tintManager.setTintColor(Color.parseColor("#99000FF")); // set a custom navigation bar resource tintManager.setNavigationBarTintResource(R.drawable.my_tint); // set a custom status bar drawable tintManager.setStatusBarTintDrawable(MyDrawable);
SystemBarConfig
Developers should not need to concern themselves with the size or positioning of the system UI. Useandroid:fitsSystemWindows="true"in
conjunction with
android:clipToPadding="false"to achieve the optimal layout for full bleed content screens that need to be
padded within the system UI bounds. However, certain elements like the
GoogleMapprovided by Google Play Services may force
you to determine the pixel insets for the system bars in order to provide the appropriate layout effect.
Use the
SystemBarConfigclass provided by
SystemBarTintManagerto
access those inset values:
SystemBarConfig config = tintManager.getConfig(); map.setPadding(0, config.getPixelInsetTop(), config.getPixelInsetRight(), config.getPixelInsetBottom());
Setup
Download and include the JAR inyour project, or add the dependency in your
build.gradle:
dependencies { compile 'com.readystatesoftware.systembartint:systembartint:1.0.3' }
相关文章推荐
- 自己动手做Android音乐播放器(续)
- Android Fragment 你应该知道的一切
- Android Binder机制浅析
- Android Fragment 真正的完全解析(下)
- Android-客户端上传多张图片到服务器功能实现
- Android Fragment 真正的完全解析(上)
- Android-采用Matrix对Bitmap加工
- Android图形编程基本概念
- 快速了解Android项目
- Android 获取手机内存存储容量信息
- android使用ViewHolder对ListView进行优化
- 通过Fragment + Viewpager+Gridview实现Android Tab切换菜单
- Android中SQLite应用详解
- ios 类似android的toast
- Android 数据存数---SQLite数据库
- Android实战简易教程-第五十七枪(分享小米手电筒源码)
- 2016最新Android安卓短信拦截(过Android4.4和Android5.0和Android5.1)源码
- Android中Popupwindow和Dialog的区别
- Android中Popupwindow和Dialog的区别
- Android中Popupwindow和Dialog的区别