【发布时间】:2016-05-05 16:40:11
【问题描述】:
我正在尝试实现类似this .我想要一个透明的工具栏/状态栏,下面有一个 ImageView。
我无法使工具栏透明,因此我尝试使用 CollapsingToolbarLayout 并移除滚动行为。它有效,但我无法使状态栏透明。
有没有办法使工具栏透明并在其下方放置一个 ImageView 或者有更好的方法来实现它?
编辑:
标准 xml 布局。到目前为止我没有改变任何东西。
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.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:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" /> </android.support.design.widget.CoordinatorLayout>
【问题讨论】:
-
只是想知道。而不是使用 colorPrimary,改变 android:background="@android:color/transparent" 有帮助吗?
-
我可以将工具栏的颜色更改为我想要的任何颜色,但我无法使其透明。如果我这样做,它仍然是 colorPrimary(蓝色)。如果我将渐变作为背景,它会出现,但背景中仍然是蓝色。
-
您有当前输出的屏幕截图吗?