的Andr​​oid完全透明的状态栏? [英] Android Completely transparent Status Bar?

查看:200
本文介绍了的Andr​​oid完全透明的状态栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了的文件的,但只发现了这一点: 链接。它是用来做酒吧的半透明。我想要做的就是让状态栏的完全透明(如下图所示的图像),并使其向后兼容的APK< 19:

我的styles.xml:

<资源的xmlns:工具=htt​​p://schemas.android.com/tool​​s>   <样式名称=AppTheme父=Theme.AppCompat.Light>   <项目名称=机器人:actionBarStyle> @style / ThemeActionBar< /项目>   <项目名称=机器人:windowActionBarOverlay>真< /项目>   <! - 支持库的兼容性 - >   <项目名称=actionBarStyle> @style / ThemeActionBar< /项目>   <项目名称=windowActionBarOverlay>真< /项目>   < /风格>   <样式名称=ThemeActionBar 父=Widget.AppCompat.Light.ActionBar.Solid>   <项目名称=机器人:背景> @null< /项目>   <! - 支持库的兼容性 - >   <项目名称=背景> @空< /项目>   <项目名称=机器人:displayOptions> showHome | useLogo< /项目>   <项目名称=displayOptions> showHome | useLogo< /项目>   < /样式> < /资源>

我能够做的:

解决方案

所有你需要做的是设置在主题中这些属性:

 <项目名称=机器人:windowTranslucentStatus>真< /项目>
<项目名称=机器人:windowTranslucentNavigation>真< /项目>
 

你希望有一个透明的状态栏

您的活动/容器布局需要此属性:

 安卓fitsSystemWindows =真
 

这是通常不能够在pre-奇巧执行这个是肯定的,看起来像你可以做到这一点的但是一些奇怪的code使得它如此

编辑:我会推荐这LIB: https://github.com/jgilfelt/SystemBarTint 了解很多pre-棒棒糖状态栏的颜色控制。

嘛想来想去,我才知道,答案完全禁用半透明或放置状态栏和导航栏棒棒糖上的任何颜色设置该标志的窗口:

 如果(Build.VERSION.SDK_INT> = Build.VERSION_ codeS.KITKAT){
            窗口瓦特= getWindow(); //在活动的onCreate()如
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
 

没有其他主题ING是必要的,它产生的是这样的:

I've searched the documentation but only found this: Link. Which is used to make the bar translucent. What I'm trying to do is to make the status bar completely transparent (as shown in the image below) and make it backward compatible for APK<19:

My styles.xml:

< resources xmlns: tools = "http://schemas.android.com/tools" >

  < style name = "AppTheme" parent = "Theme.AppCompat.Light" >
  < item name = "android:actionBarStyle" > @style / ThemeActionBar < /item>
  <item name="android:windowActionBarOverlay">true</item >
  <!-- Support library compatibility -->
  < item name = "actionBarStyle" > @style / ThemeActionBar < /item>
  <item name="windowActionBarOverlay">true</item >
  </style >

  < style name = "ThemeActionBar"
parent = "Widget.AppCompat.Light.ActionBar.Solid" >
  < item name = "android:background" > @null < /item>
  <!-- Support library compatibility -->
  <item name="background">@null</item >
  < item name = "android:displayOptions" > showHome | useLogo < /item>
  <item name="displayOptions">showHome|useLogo</item >

  < /style>

</resources >

What I was able to do:

解决方案

All you need to do is set these properties in your theme:

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>

Your activity / container layout you wish to have a transparent status bar needs this property set:

android:fitsSystemWindows="true"

It is generally not possible to perform this for sure on pre-kitkat, looks like you can do it but some strange code makes it so.

EDIT: I would recommend this lib: https://github.com/jgilfelt/SystemBarTint for lots of pre-lollipop status bar color control.

Well after much deliberation I've learned that the answer to totally disabling the translucency or any color placed on the status bar and navigation bar for lollipop is to set this flag on the window:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow(); // in Activity's onCreate() for instance
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }

No other theme-ing is necessary, it produces something like this:

这篇关于的Andr​​oid完全透明的状态栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆