Code Monkey home page Code Monkey logo

ultimatebar's Introduction

UltimateBar

透明状态栏导航栏、沉浸式状态栏导航栏的终极解决方案

特点:

1.四种效果,自定义颜色的状态栏和导航栏,半透明状态栏和导航栏, 沉浸式状态栏和导航栏,隐藏状态栏和导航栏;

2.可以自定义状态栏和导航栏的颜色和透明度;

3.KITKAT(Android 4.4)和LOLLIPOP(Android 5.0)上显示效果高度统一。

使用方法:

首先添加依赖:

compile 'org.zackratos:ultimatebar:1.0.3'



1.自定义颜色的状态栏和导航栏

在 onCreate() 方法中:

UltimateBar ultimateBar = new UltimateBar(this);
ultimateBar.setColorBar(ContextCompat.getColor(this, R.color.DeepSkyBlue));





如果需要设置不透明度:

UltimateBar ultimateBar = new UltimateBar(this);
ultimateBar.setColorBar(ContextCompat.getColor(this, R.color.SpringGreen), 50);







2.半透明状态栏和导航栏

在 onCreate() 方法中:

UltimateBar ultimateBar = new UltimateBar(this);
ultimateBar.setTransparentBar(Color.BLUE, 50);







3.沉浸式状态栏和导航栏:

在 onCreate() 方法中:

UltimateBar ultimateBar = new UltimateBar(this);
ultimateBar.setImmersionBar();







4.隐藏状态栏和导航栏:

在 onWindowFocusChanged() 方法中:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        UltimateBar ultimateBar = new UltimateBar(this);
        ultimateBar.setHintBar();
    }
}







5.在 DrawerLayout 中设置自定义颜色的状态栏和导航栏:

首先需要设置 DrawerLayout 下面的主局部中添加 android:fitsSystemWindows="true":

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical">
    </LinearLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/SpringGreen"
        android:layout_gravity="left"/>

</android.support.v4.widget.DrawerLayout>

注意是 DrawerLayout 下面的主布局,DrawerLayout 本身和抽屉布局都不能添加。

然后在 onCreate() 方法中:

UltimateBar ultimateBar = new UltimateBar(this);
ultimateBar.setColorBarForDrawer(ContextCompat.getColor(this, R.color.DeepSkyBlue));





如果需要设置不透明度:

UltimateBar ultimateBar = new UltimateBar(this);
ultimateBar.setColorBarForDrawer(ContextCompat.getColor(this, R.color.DeepSkyBlue), 50);





更新日志

v1.0.3

1.在 Android 4.4 中使用自定义颜色的状态栏和导航栏的时候,如果没有导航栏,不设置导航栏。

v1.0.2

1.增加 DrawerLayout 使用的自定义颜色的状态栏和导航栏。

v1.0.1

1.判断当状态栏不存在时,不对状态栏进行设置;

2.自定义颜色的状态栏和导航栏中,当加深程度为 0 时,直接设置为原颜色,即不加深颜色;

3.半透明的状态栏和导航栏中,当不透明度为 0 时,直接设为完全透明,即不进行不透明度计算;

4.修改包名。

v1.0.0

1.四种效果,自定义颜色的状态栏和导航栏,半透明状态栏和导航栏, 沉浸式状态栏和导航栏,隐藏状态栏和导航栏;

2.可以自定义状态栏和导航栏的颜色和透明度;

3.KITKAT(Android 4.4)和LOLLIPOP(Android 5.0)上显示效果高度统一。

License

Copyright 2017 Zackratos

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.

ultimatebar's People

Contributors

zackratos avatar

Watchers

James Cloos avatar lihan2734 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.