SystemBarTint沉浸式通知栏

SystemBarTint Github 下载地址:https://github.com/jgilfelt/SystemBarTint

首先看官方文档对于本开源库的介绍:

Android System Bar Tint

应用背景着色Android系统UI当使用KitKat半透明的模式。

03235413_9K79.jpg

Android 4.4(KitKat)介绍了半透明的系统UI样式地位和导航栏。 这些风格的壁纸的基础活动,比如主屏幕发射器,但提供的最低背景保护使他们更有用的其他类型的活动,除非你提供自己的背景在你的布局。 确定大小,位置和系统用户界面的存在对于一个给定的设备配置可以不平凡的。

这个库提供了一个简单的方法来创建一个背景系统的“色彩”酒吧,无论是颜色值或可移动。 默认情况下它会给你一种半透明的黑色背景,将用于全出血屏幕持续系统UI内容仍然是重要的——比如当放置在地图或照片网格。 

Usage(用法)

你必须首先使半透明活动——通过使用或继承的各种*。 TranslucentDecor主题,通过设置android:windowTranslucentNavigation或android:windowTranslucentStatus主题属性为true或通过应用FLAG_TRANSLUCENT_NAVIGATION或FLAG_TRANSLUCENT_STATUS国旗活动窗口的代码。

如果没有启用半透明或应用程序运行在一个平台API版本早于19日系统界面将显示为正常。 你不应该使用全屏时使着色或浸入式窗口模式。 您可以安全地使用这个库在Android版本API 10。

使色彩: 

@Overrideprotected
 void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
        // create our manager instance after the content view is set
    SystemBarTintManager tintManager = new SystemBarTintManager(this);  
      // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);  
      // enable navigation bar tint
    tintManager.setNavigationBarTintEnabled(true);
}

提供自定义色彩颜色值或画板:

// set a custom tint color for all 
system barstintManager.setTintColor(Color.parseColor("#99000FF"));
// set a custom navigation bar 
resourcetintManager.setNavigationBarTintResource(R.drawable.my_tint);
// set a custom status bar 
drawabletintManager.setStatusBarTintDrawable(MyDrawable);

SystemBarConfig

开发人员应该不需要关心系统的大小或定位UI。 使用android:fitsSystemWindows = " true "与android:clipToPadding =“false”实现的最优布局全出血内容屏幕需要垫在系统界面范围内。 然而,某些元素(如GoogleMap谷歌提供的服务可能会迫使你玩来确定系统的像素insets酒吧为了提供适当的布局效果。

使用SystemBarConfig类提供的SystemBarTintManager访问那些插图值: 

SystemBarConfig config = tintManager.getConfig();
map.setPadding(0, config.getPixelInsetTop(), config.getPixelInsetRight(), config.getPixelInsetBottom());

Setup

Download and include the JAR in your project, or add the dependency in your build.gradle:

dependencies {
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'}

This repository also includes a sample app which you can download from Google Play:

看了官方文档,那么我们如何实现呢?

首先官方文档提出:

你必须首先使半透明活动——通过使用或继承的各种*。 TranslucentDecor主题,通过设置android:windowTranslucentNavigation或android:windowTranslucentStatus主题属性为true或通过应用FLAG_TRANSLUCENT_NAVIGATION或FLAG_TRANSLUCENT_STATUS国旗活动窗口的代码。

TranslucentDecor是Android 4.4 提供的一个主题


详细请参考实例代码


转载于:https://my.oschina.net/whhos/blog/669345

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值