Reputation: 461
https://github.com/codepath/android_guides/wiki/Using-the-App-ToolBar
https://github.com/chrisbanes/cheesesquare
I saw an example, I've implemented a toolbar.
Toolbar for example, works as follows.
1) Expanded
2) Collapsed
But, I want to show the background, or the toolbar is transparent when the toolbar is collapsed. How can I implement the following? Like this...
Upvotes: 2
Views: 1226
Reputation: 1368
To get a transparent background through layout XML use:
app:contentScrim="@android:color/transparent"
To do it programmatically:
collapsingToolbar.setContentScrimColor(Color.TRANSPARENT);
collapsingToolbar.setStatusBarScrimColor(Color.TRANSPARENT);
Upvotes: 0
Reputation: 5100
To ensure that the background is transparent when the toolbar is collapsed make sure that the contentScrim
is not set to transparent.
Here is an example of wht your layout might look like.
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="@android:color/transparent">
Upvotes: 1
Reputation: 2664
Add this to your Collapsing Layout in your layouts,
app:contentScrim="@android:color/transparent"
Example
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
Upvotes: 0