Giter Site home page Giter Site logo

hierarchyang / ultimatebarx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zackratos/ultimatebarx

0.0 1.0 0.0 14.08 MB

Make Android transparent statusbar and navigationbar easy.

Home Page: https://juejin.im/post/5f03e8786fb9a07e5e58c623

License: Apache License 2.0

Kotlin 98.63% Java 1.37%

ultimatebarx's Introduction

UltimateBarX

一款方便的设置状态栏和导航栏的各种效果的框架

  • 可以设置各种效果,透明、半透明、固定颜色、布局是否侵入等
  • 状态栏和导航栏分开设置,互不影响
  • 支持 Android 4.4 以上,各系统版本的现实效果高度统一
  • 支持 Activity 和 Fragment
  • 同一个 Activity 或 Fragment 可以多次设置不同的效果

使用方法

在 gradle 中添加

dependencies {
    implementation 'com.zackratos.ultimatebarx:ultimatebarx:0.2.2'
}

设置状态栏

在 Activity 或 Fragment 中

UltimateBarX.create(UltimateBarX.STATUS_BAR)        // 设置状态栏
    .fitWindow(true)                                // 布局是否侵入状态栏(true 不侵入,false 侵入)  
    .bgColor(Color.BLACK)                           // 状态栏背景颜色(色值)
    .bgColorRes(R.color.deepSkyBlue)                // 状态栏背景颜色(资源id)
    .bgRes(R.drawable.bg_gradient)                  // 状态栏背景 drawable
    .light(false)                                   // light模式(状态栏字体灰色 Android 6.0 以上支持)
    .apply(this)

设置导航栏

在 Activity 或 Fragment 中

UltimateBarX.create(UltimateBarX.NAVIGATION_BAR)    // 设置导航栏
    .fitWindow(true)                                // 布局是否侵入导航栏(true 不侵入,false 侵入)  
    .bgColor(Color.BLACK)                           // 导航栏背景颜色(色值)
    .bgColorRes(R.color.deepSkyBlue)                // 导航栏背景颜色(资源id)
    .bgRes(R.drawable.bg_gradient)                  // 导航栏背景 drawable
    .light(false)                                   // light模式(导航栏按钮灰色 Android 8.0 以上支持)
    .apply(this)
  • 设置背景的三个方法写一个即可,优先级 bgRes > bgColor > bgColorRes
  • 如果要在 Fragment 中使用,Fragment 的根布局必须是 ViewGroup

快速设置状态栏透明

在 Activity 或 Fragment 中

UltimateBarX.create(UltimateBarX.STATUS_BAR)
    .transparent(true)
    .apply(this)

跟下面的写法效果是一样的

UltimateBarX.create(UltimateBarX.STATUS_BAR)
    .fitWindow(false)
    .bgColor(Color.TRANSLUCENT)
    .apply(this)

快速设置导航栏透明的方法也类似,把 UltimateBarX.STATUS_BAR 改成 UltimateBarX.NAVIGATION_BAR 即可

截图

 

 

 

Change Log

CHANGELOG

License

Copyright 2020 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.

ultimatebarx's People

Contributors

zackratos avatar

Watchers

James Cloos 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.