为什么我们不能用一个半透明系统酒吧与和动作条 [英] Why can't we use a Translucent system bars with and ActionBar

查看:169
本文介绍了为什么我们不能用一个半透明系统酒吧与和动作条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在更新我的应用程序,以奇巧,我只是想用半透明财产给他们一个华丽的外观上奇巧:

While updating my apps to Kitkat, I just wanted to give them a gorgeous look on KitKat using the Translucent property:

半透明系统酒吧

现在,您可以使系统栏部分透明的新主题,Theme.Holo.NoActionBar.TranslucentDecor和Theme.Holo.Light.NoActionBar.TranslucentDecor。通过启用半透明系统吧,你的布局将填补背后的系统栏的区域,所以你也必须启用[fitsSystemWindows] [4]为你的布局不应该包括在系统栏的部分。

You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable [fitsSystemWindows][4] for the portion of your layout that should not be covered by the system bars.

我唯一担心的是,我想用一个动作条这听起来谷歌想要的东西两者主题对面(有NoActionBar:

My only concern is that I would like to use an ActionBar which sounds the opposite of what Google wants (both theme have NoActionBar:

Theme.Holo.NoActionBar.TranslucentDecor 
Theme.Holo.Light.NoActionBar.TranslucentDecor 

由于我不打算使用一些黑客或技巧,使其工作,我只是想知道,如果有一些达到这个正确的方法,或者这将是对谷歌的指导方针。

As I don't plan to use some hacks or tricks to make it work, I just wanted to know if there was some correct way to achieve this or if this would be against Google guidelines.

推荐答案

您可以创建自己的主题与 android.R.attr#windowTranslucentStatus 设置为来达到同样的效果不失动作条

You can create your own theme with android.R.attr#windowTranslucentStatus set to true to achieve the same effect without losing the ActionBar.

从文档

标志,指示此窗口是否请求一个半透明的状态栏。   对应                到{@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS}。

Flag indicating whether this window requests a translucent status bar. Corresponds to {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS}.

样式 - 请记住,这些会去值-V19

Styles - Remember, these would go in values-v19.

<style name="TranslucentStatusBar" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/TranslucentActionBar</item>
    <item name="android:windowTranslucentNavigation">false</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

<style name="TranslucentActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@android:color/transparent</item>
</style>

布局

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_blue_dark"
    android:fitsSystemWindows="true" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/holo_purple" />

</FrameLayout>

结果

这篇关于为什么我们不能用一个半透明系统酒吧与和动作条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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