StatusBarUtil-master

所属分类:Java编程
开发工具:Java
文件大小:2252KB
下载次数:1
上传日期:2017-12-23 14:07:29
上 传 者wektorious
说明:  A util for setting status bar style on Android App.

文件列表:
ChangeLog.md (1714, 2017-05-02)
LICENSE.md (11357, 2017-05-02)
build.gradle (627, 2017-05-02)
gradle.properties (823, 2017-05-02)
gradle (0, 2017-05-02)
gradle\wrapper (0, 2017-05-02)
gradle\wrapper\gradle-wrapper.jar (53636, 2017-05-02)
gradle\wrapper\gradle-wrapper.properties (230, 2017-05-02)
gradlew (4971, 2017-05-02)
gradlew.bat (2314, 2017-05-02)
img (0, 2017-05-02)
img\set_color.png (13076, 2017-05-02)
img\set_color_for_drawer_layout.png (31601, 2017-05-02)
img\set_color_for_swipe_back_page.png (33954, 2017-05-02)
img\set_for_image_view_page.png (145095, 2017-05-02)
img\set_translucnet.png (109432, 2017-05-02)
img\set_transparent.png (93417, 2017-05-02)
img\status_bar_util.png (15487, 2017-05-02)
img\use_in_fragment.gif (1190885, 2017-05-02)
library (0, 2017-05-02)
library\build.gradle (2949, 2017-05-02)
library\proguard-rules.pro (664, 2017-05-02)
library\src (0, 2017-05-02)
library\src\androidTest (0, 2017-05-02)
library\src\androidTest\java (0, 2017-05-02)
library\src\androidTest\java\com (0, 2017-05-02)
library\src\androidTest\java\com\example (0, 2017-05-02)
library\src\androidTest\java\com\example\library (0, 2017-05-02)
library\src\androidTest\java\com\example\library\ApplicationTest.java (350, 2017-05-02)
library\src\main (0, 2017-05-02)
library\src\main\AndroidManifest.xml (137, 2017-05-02)
library\src\main\java (0, 2017-05-02)
library\src\main\java\com (0, 2017-05-02)
library\src\main\java\com\jaeger (0, 2017-05-02)
library\src\main\java\com\jaeger\library (0, 2017-05-02)
library\src\main\java\com\jaeger\library\StatusBarUtil.java (27435, 2017-05-02)
... ...

# StatusBarUtil [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StatusBarUtil-green.svg?style=true)](https://android-arsenal.com/details/1/3341) [![Download](https://api.bintray.com/packages/laobie/maven/statusbarutil/images/download.svg) ](https://bintray.com/laobie/maven/statusbarutil/_latestVersion) A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4). [中文版点我](http://laobie.github.io/android/2016/03/27/statusbar-util.html) ![](img/status_bar_util.png) ### Sample [Download StatusBarUtil-Demo](http://fir.im/5mnp) ### ChangeLog [Click Me](ChangeLog.md) ### Usage 1. Add the dependencies to your build.gradle file, StatusBarUtil is avaiable in JCenter: ```groovy compile 'com.jaeger.statusbarutil:library:1.4.0' ``` I fixed typo, change "statusbaruitl" to "statusbarutil", please notice this. 2. Call method you need after `setContentView()`, such as : ```java 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: ```xml ... ``` 4. Set color for swipe back page Recommend using with [bingoogolapple/BGASwipeBackLayout\-Android: Android Activity 滑动返回](https://github.com/bingoogolapple/BGASwipeBackLayout-Android) ```java 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](https://github.com/laobie/StatusBarUtil/blob/master/sample/src/main/java/com/jaeger/statusbarutil/UseInFragmentActivity.java) Handle all Fragments in ViewPager as ImageViewFragment, add a fake View in your Fragment layout as StatusBar : ```xml ``` The fake StatusBar View height value ` statusbar_view_height` defined in `dimens.xml` ```xml ~ values-v19/dimens.xml 25dp ~ values/dimens.xml 0dp ``` When you change StatusBarColor : ```java mFakeStatusBar.setBackgroundColor(color); ``` Then in the Activity which contains ViewPage, just invoke ```java StatusBarUtil.setTranslucentForImageViewInFragment(UseInFragmentActivity.this, null); ``` Please read [UseInFragmentActivity.java](https://github.com/laobie/StatusBarUtil/blob/master/sample/src/main/java/com/jaeger/statusbarutil/UseInFragmentActivity.java) ### Features - Set status bar color ```java StatusBarUtil.setColor(Activity activity, int color) ``` ![](img/set_color.png) - Set status bar translucent ```java StatusBarUtil.setTranslucent(Activity activity, int statusBarAlpha) ``` ![](img/set_translucnet.png) - Set status bar transparent ```java StatusBarUtil.setTransparent(Activity activity) ``` ![](img/set_transparent.png) - Set status bar color for `DrawerLayout` ```java StatusBarUtil.setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color) ``` ![](img/set_color_for_drawer_layout.png) - Set translucent status bar for using ImageView as head view page ```java StatusBarUtil.setTranslucentForImageView(Activity activity, int statusBarAlpha, View needOffsetView) ``` ![](img/set_for_image_view_page.png) - Use in fragment ![](img/use_in_fragment.gif) - Set color for swipe back page ```java StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha) ``` ![](img/set_color_for_swipe_back_page.png) - Pass statusBarAlpha param when necessary to change your status bar alpha, which is 112 by default. ### License Copyright 2016 Jaeger Chen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

近期下载者

相关文件


收藏者