{"id":13396435,"url":"https://github.com/laobie/StatusBarUtil","last_synced_at":"2025-03-13T23:31:09.237Z","repository":{"id":37822035,"uuid":"51727325","full_name":"laobie/StatusBarUtil","owner":"laobie","description":"A util for setting status bar style on Android App.","archived":false,"fork":false,"pushed_at":"2022-06-24T09:55:37.000Z","size":9364,"stargazers_count":8810,"open_issues_count":111,"forks_count":1724,"subscribers_count":182,"default_branch":"master","last_synced_at":"2024-10-29T15:48:40.850Z","etag":null,"topics":["android","statusbar","statusbarutil","utils"],"latest_commit_sha":null,"homepage":"http://t.cn/Rq746Kb","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laobie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE_LOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-15T03:06:06.000Z","updated_at":"2024-10-29T07:30:08.000Z","dependencies_parsed_at":"2022-08-03T15:19:01.200Z","dependency_job_id":null,"html_url":"https://github.com/laobie/StatusBarUtil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laobie%2FStatusBarUtil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laobie%2FStatusBarUtil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laobie%2FStatusBarUtil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laobie%2FStatusBarUtil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laobie","download_url":"https://codeload.github.com/laobie/StatusBarUtil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243499966,"owners_count":20300727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","statusbar","statusbarutil","utils"],"created_at":"2024-07-30T18:00:51.462Z","updated_at":"2025-03-13T23:31:09.208Z","avatar_url":"https://github.com/laobie.png","language":"Java","readme":"# StatusBarUtil\n\n[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StatusBarUtil-green.svg?style=true)](https://android-arsenal.com/details/1/3341)\n\n[ ![Download](https://api.bintray.com/packages/laobie/maven/StatusBarUtil/images/download.svg) ](https://bintray.com/laobie/maven/StatusBarUtil/_latestVersion)\n\nA util for setting status bar style on Android App. It can work above API 19(KitKat 4.4).\n\n\n[中文版点我](http://laobie.github.io/android/2016/03/27/statusbar-util.html)\n\n![](https://s9.postimg.cc/3p0itrz67/DRIVE_2.png)\n\n### Sample\n\n[Download StatusBarUtil-Demo](http://fir.im/5mnp)\n\n### ChangeLog \n\n[CLICK ME](CHANGE_LOG.md)\n\n### Usage\n\n1. Add the dependencies to your build.gradle file, StatusBarUtil is avaiable in JCenter:\n\n   ```groovy\n   compile 'com.jaeger.statusbarutil:library:1.5.1'\n   ```\n\n   I fixed typo, change \"statusbaruitl\" to \"statusbarutil\", please notice this.\n\n2. Call method you need after `setContentView()`,  such as :\n\n   ```java\n   setContentView(R.layout.main_activity);\n   ...\n   StatusBarUtil.setColor(MainActivity.this, mColor);\n   ```\n\n3. If you use this util in a page which containing a `DrawerLayout`, you need add `android:fitsSystemWindows=\"true\"` for `DrawerLayout` in your layout XML:\n\n   ```xml\n   \u003candroid.support.v4.widget.DrawerLayout\n       xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n       android:id=\"@+id/drawer_layout\"\n       android:layout_width=\"match_parent\"\n       android:layout_height=\"match_parent\"\n       android:fitsSystemWindows=\"true\"\u003e\n\n       ...\n\n   \u003c/android.support.v4.widget.DrawerLayout\u003e\n   ```\n\n4. Set color for swipe back page\n\n   Recommend using  with [bingoogolapple/BGASwipeBackLayout\\-Android: Android Activity 滑动返回](https://github.com/bingoogolapple/BGASwipeBackLayout-Android)\n\n   ```java\n   StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)\n   ```\n\n5. All `statusBarAlpha` value you set should between 0 ~ 255\n\n6. 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) \n\n   Handle all Fragments in ViewPager as ImageViewFragment, add a fake View in your Fragment layout as StatusBar :\n\n   ```xml\n   \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n   \u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:layout_width=\"match_parent\"\n       android:layout_height=\"match_parent\"\n       android:orientation=\"vertical\"\u003e\n\n       \u003cView\n           android:id=\"@+id/fake_statusbar_view\"\n           android:layout_width=\"match_parent\"\n           android:layout_height=\"@dimen/statusbar_view_height\"\n           android:background=\"@color/colorPrimary\"/\u003e\n\n       \u003cTextView\n           android:id=\"@+id/tv_title\"\n           android:layout_width=\"match_parent\"\n           android:layout_height=\"56dp\"\n           android:background=\"@color/colorPrimary\"\n           android:gravity=\"center\"\n           android:text=\"@string/app_name\"\n           android:textColor=\"@color/white\"\n           android:textSize=\"24sp\"/\u003e   \n   \u003c/LinearLayout\u003e\n   ```\n\n   The fake StatusBar View height value ` statusbar_view_height`  defined in `dimens.xml`\n\n   ```xml\n   ~ values-v19/dimens.xml\n\n   \u003cdimen name=\"statusbar_view_height\"\u003e25dp\u003c/dimen\u003e\n\n   ~ values/dimens.xml\n\n   \u003cdimen name=\"statusbar_view_height\"\u003e0dp\u003c/dimen\u003e\n   ```\n\n   When you change StatusBarColor :\n\n   ```java\n   mFakeStatusBar.setBackgroundColor(color);\n   ```\n\n   Then in the Activity which contains ViewPage, just invoke\n\n   ```java\n   StatusBarUtil.setTranslucentForImageViewInFragment(UseInFragmentActivity.this, null);\n   ```\n\n   Please read [UseInFragmentActivity.java](https://github.com/laobie/StatusBarUtil/blob/master/sample/src/main/java/com/jaeger/statusbarutil/UseInFragmentActivity.java) \n\n### Features\n\n- Set status bar color\n\n  ```java\n  StatusBarUtil.setColor(Activity activity, int color)\n  ```\n\n  ![](img/set_color.png)\n\n- Set status bar translucent\n\n  ```java\n  StatusBarUtil.setTranslucent(Activity activity, int statusBarAlpha)\n  ```\n\n  ![](img/set_translucnet.png)\n\n- Set status bar transparent\n\n  ```java\n  StatusBarUtil.setTransparent(Activity activity)\n  ```\n\n  ![](img/set_transparent.png)\n\n- Set status bar color for `DrawerLayout`\n\n  ```java\n  StatusBarUtil.setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color)\n  ```\n\n  ![](img/set_color_for_drawer_layout.png)\n\n- Set translucent status bar for using ImageView as head view page\n\n  ```java\n    StatusBarUtil.setTranslucentForImageView(Activity activity, int statusBarAlpha, View needOffsetView)\n  ```\n   ![](img/set_for_image_view_page.png)\n\n\n- Set Light or Dark mode\n\n  ```\n    StatusBarUtil.setLightMode(Activity activity)\n    StatusBarUtil.setDarkMode(Activity activity)\n  ```\n    ![](img/switch_light_mode.jpeg)\n\n- Use in fragment\n\n   ![](img/use_in_fragment.gif)\n\n- Set color for swipe back page\n\n  ```java\n    StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)\n  ```\n\n    ![](img/set_color_for_swipe_back_page.png)\n\n- Pass statusBarAlpha param when necessary to change your status bar alpha, which is 112 by default.\n\n\n### License\n\n\tCopyright 2016 Jaeger Chen\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\t\n\t\thttp://www.apache.org/licenses/LICENSE-2.0\n\t\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n","funding_links":[],"categories":["Index `(light-weight pages)`","状态栏","Index","Java","Android应用","Libs"],"sub_categories":["资源传输下载","\u003cA NAME=\"Utility\"\u003e\u003c/A\u003eUtility"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaobie%2FStatusBarUtil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaobie%2FStatusBarUtil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaobie%2FStatusBarUtil/lists"}