GithubHelp home page GithubHelp logo

leon2017 / status-bar-compat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from msdx/status-bar-compat

0.0 2.0 0.0 178 KB

A compatible library for setting status bar color. Support Xiaomi, Flyme, EMUI3.1.

License: Apache License 2.0

Java 100.00%

status-bar-compat's Introduction

StatusBarCompat

Build Status Download Methods

简介

StatusBarCompat是一个用于设置系统状态栏颜色的兼容库,兼容Android 4.4.2(API 19)以上,使用简单,仅需要一行代码的调用。

效果展示

5.1.1运行效果 6.0深色状态栏白色文字 6.0浅色状态栏黑色文字

使用方式

声明仓库

确保在你的根项目的build.gradle中对jcenter的声明:

allprojects {
    repositories {
        jcenter()
    }
}

声明依赖

在你要使用的module的build.gradle文件中声明以下依赖:

    compile 'com.githang:status-bar-compat:0.5.2'

代码调用

最后在你的Activity的setContentView()方法调用之后,调用以下方法即可。

    StatusBarCompat.setStatusBarColor(this, color, lightStatusBar);

或者是

    StatusBarCompat.setStatusBarColor(this, color);

API文档

API文档参见:https://msdx.github.io/status-bar-compat/

#适配支持情况

第三方ROM适配支持

ROM 适配说明
MIUI 调用小米的API适配
Flyme 调用魅族API适配,并且增加不主动设置可能不兼容的Flyme的状态栏的API
EMUI3.1 对于6.0以下5.0及其以上的EMUI,使用4.4.2的方式来处理(EMUI3.1无法使用5.0API设置)

##设置失败的机型

型号 系统版本 备注
高通 Andriod L Device1 4.4.4(SDK 19) 状态栏还是为黑色

深色状态栏图标设置支持

  • Android 6.0及以上
  • Flyme
  • MIUI

6.0以下的其他机型因未提供相关API可以把状态栏图标设置为黑色,所以无法支持。请不要再提不在上述范围的手机无法设置深色图标的issue了。

已知的设置状态栏为白色后看不清时间的机型

把状态栏设置为白色或接近白色的颜色可能导致部分机型看不清状态栏的图标与文字,原因是这些机型把设置状态栏半透明改成了全透明,而Android 6.0以下没有官方的API可以把状态栏的图标及字体设置为深色,需要定制的ROM自己提供API支持。因此,不建议把状态栏设置为白色或接近白色的颜色。

目前已知的提供了支持的ROM有MIUI以及Flyme。以下是已知的不支持的机型列表:

型号 系统版本 备注
华硕 K010 4.4.2(SDK 19) 白色字体但有阴影
Lenovo TAB S8-50F 4.4.2(SDK 19) 完全看不到时间
联想 A936 4.4.4(SDK 19) 同上
联想 K80M 4.4.4(SDK 19) 同上

以上具体机型测试结果根据在Testin上随机兼容性测试所得,测试报告地址:http://realauto.testin.cn/s/1amaujufn

已知问题

  • 由于低于6.0以下的系统使用透明状态栏并设置fitsSystemWindows来实现设置状态栏颜色,在一些底部虚拟导航栏给隐藏的机型上,可能会出现界面无法显示在该区域中。如果遇到此问题,你需要把你的App theme指定为AppCompat里的一种。

参考资料:

status-bar-compat's People

Contributors

msdx avatar

Watchers

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