透明操作栏不完全透明。 (离开weirdbox)

Transparent action bar not being fully transparent. (Leaves weirdbox)

我尝试将我为我的应用程序定制的操作栏设置为透明。然而,它不是完全透明的,而是留下了一个奇怪的高程阴影:

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>

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

    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));

但尽管如此,框(显示在 link 中)仍然存在...我不确定发生了什么?有人看到我的代码有什么问题吗?

尝试将应用栏放入内部

app:elevation="0dp"

这个在你的工具栏里

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

我认为您需要使用 "android:alpha="0.5" 或使用 setAlpha() 方法。

我试过了,它对我有用,并将这四行添加到 xml 文件的工具栏小部件中。

app:contentInsetEnd="0dp"
            app:contentInsetLeft="0dp"
            app:contentInsetRight="0dp"
            app:contentInsetStart="0dp"