透明的ActionBar和的状态栏。在Android的棒棒糖 [英] Transparent actionBar and statusBar in Android lollipop

查看:199
本文介绍了透明的ActionBar和的状态栏。在Android的棒棒糖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建这个接口:

这里是我的实际结果是:

And here is my actual result :

  • 在状态栏非常透明,我们看到我的形象作为背景:确定
  • 在操作栏不是透明的:NOK

下面是我的主题,我使用这项活动的code:

Here is the code of my theme that i use for this activity :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- inherit from the material theme -->
    <style name="MaterialAppDetailTheme" parent="android:Theme.Material.Light">


        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowActionBarOverlay">true</item>

        <!-- enable window content transitions -->
        <item name="android:windowContentTransitions">true</item>

        <!-- specify shared element transitions -->
        <item name="android:windowSharedElementEnterTransition">
            @transition/change_image_transform</item>
        <item name="android:windowSharedElementExitTransition">
            @transition/change_image_transform</item>

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

</style>

推荐答案

您可以更改工具栏的颜色为透明这样的:

You can change your toolbar color to transparent like this:

mToolbar.setBackgroundColor(getResources().getColor(android.R.color.transparent));

您可以改变它的背景上的XML太:

You can change it's background on the XML too:

android:background="@android:color/transparent"

或者,如果您使用的是动作条:

Or if you're using ActionBar:

getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

使用 getActionBar()如果你不使用 ActionBarActivity

结果:

这篇关于透明的ActionBar和的状态栏。在Android的棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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