I am not able to change the color of CollapsingToolbarLayout When I roll up it gets the image I placed and does not change the color.
Before:
Then:
I wanted to take the image and leave the toolbar transparent.
You can add contentScrim
CollapsingToolbarLayout
and leave the toolbar background transparent, but with opacity, or if you prefer with a solid color. Since you did not put any code, it would look something like this:
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:scaleType="centerCrop"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
Asshownintheimageabove,thecolorofToolbar
issolid.Tobetransparent,simplychangethevaluefromcontentScreem
toacolorthathasopacity.Forexampleapp:contentScrim="#77000000"
. See the image below: