https://github.com/laobie/StatusBarUtil  推荐

Sample

Download StatusBarUtil-Demo

ChangeLog

CLICK ME

Usage

  1. Add the dependencies to your build.gradle file, StatusBarUtil is avaiable in JCenter:

    compile 'com.jaeger.statusbarutil:library:1.5.1'

    I fixed typo, change "statusbaruitl" to "statusbarutil", please notice this.

  2. Call method you need after setContentView(), such as :

    setContentView(R.layout.main_activity);...StatusBarUtil.setColor(MainActivity.this, mColor);
  3. If you use this util in a page which containing a DrawerLayout, you need add android:fitsSystemWindows="true" for DrawerLayout in your layout XML:

        ...
  4. Set color for swipe back page

    Recommend using with bingoogolapple/BGASwipeBackLayout-Android: Android Activity 滑动返回

    StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)
  5. All statusBarAlpha value you set should between 0 ~ 255

  6. How to use in Fragment, please read UseInFragmentActivity.java

    Handle all Fragments in ViewPager as ImageViewFragment, add a fake View in your Fragment layout as StatusBar :

    <?xml version="1.0" encoding="utf-8"?>           

    The fake StatusBar View height value statusbar_view_height defined in dimens.xml

    ~ values-v19/dimens.xml25dp~ values/dimens.xml0dp

    When you change StatusBarColor :

    mFakeStatusBar.setBackgroundColor(color);

    Then in the Activity which contains ViewPage, just invoke

    StatusBarUtil.setTranslucentForImageViewInFragment(UseInFragmentActivity.this, null);

    Please read UseInFragmentActivity.java

Features

  • Set status bar color

    StatusBarUtil.setColor(Activity activity, int color)

  • Set status bar translucent

    StatusBarUtil.setTranslucent(Activity activity, int statusBarAlpha)

  • Set status bar transparent

    StatusBarUtil.setTransparent(Activity activity)

  • Set status bar color for DrawerLayout

    StatusBarUtil.setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color)

  • Set translucent status bar for using ImageView as head view page

      StatusBarUtil.setTranslucentForImageView(Activity activity, int statusBarAlpha, View needOffsetView)

  • Set Light or Dark mode

      StatusBarUtil.setLightMode(Activity activity)  StatusBarUtil.setDarkMode(Activity activity)

  • Use in fragment

  • Set color for swipe back page

      StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)

  • Pass statusBarAlpha param when necessary to change your status bar alpha, which is 112 by default.

License

更多相关文章

  1. 为android封装的百度定位组件
  2. Android(安卓)gallery与BaseaDapter的使用
  3. android 开源项目(城市定位)
  4. Android(安卓)SeekBar(拖动条)
  5. android ViewPager 竖向滑动
  6. android webview点击返回键回到上一个html
  7. textView自动滑动
  8. Android点击左右按钮实现左右滑动页面切换
  9. android之无返回结果跳转intent

随机推荐

  1. Android make脚本简记
  2. Android(安卓)UI:筛选条的简单实现
  3. Android错误解决 Call requires API leve
  4. android登录tomcat服务器并查找数据库的
  5. android飞机游戏敌机移动路径
  6. Android最基本的异步网络请求框架
  7. Android(安卓)KitCat 4.4.2 ADB 官方所支
  8. Android系统添加自己写的工具
  9. Android中的Ninja简介
  10. android 项目R文件丢失解决办法