透明操作栏不是完全透明的. (留下怪异的盒子) [英] Transparent action bar not being fully transparent. (Leaves weirdbox)

查看:104
本文介绍了透明操作栏不是完全透明的. (留下怪异的盒子)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将为我的应用程序定制的操作栏设置为透明.但是,不是完全透明,而是留下了怪异的高程阴影:

I've tried setting the action bar I custom-made for my application to be transparent. However instead of being completely transparent, it leaves a weird elevation shadow:

http://puu.sh/rdYyb/04ce0147f6.jpg

栏的XML:

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbarlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize" />

</android.support.design.widget.AppBarLayout>


<android.support.design.widget.FloatingActionButton
    android:id="@+id/OverviewFAB"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@drawable/ic_add_alert" />

<RelativeLayout
    android:id="@+id/main_fragment_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

我主题的样式XML:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"></style>

我如何以编程方式尝试删除活动中的高程和背景:

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbarlayout);
    appBarLayout.setElevation(0);
    toolbar.setElevation(0);
    appBarLayout.setBackgroundColor(ContextCompat.getColor(this, android.R.color.transparent));
    toolbar.setBackgroundColor(ContextCompat.getColor(this, android.R.color.transparent));

但是尽管如此,该框(在链接中显示)仍然存在...我不确定这是怎么回事?有人在我的代码中看到任何错误吗?

But despite all this the box (shown in the link) still persists... I'm not sure what's going on? Does anyone see anything wrong in my code?

推荐答案

尝试将其放入应用栏

app:elevation="0dp"

这在您的工具栏中

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

这篇关于透明操作栏不是完全透明的. (留下怪异的盒子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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