haha
haha

Reputation: 461

How to implement collapsing toolbar with no toolbar

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

enter image description here

2) Collapsed

enter image description here

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...

enter image description here

Upvotes: 2

Views: 1226

Answers (3)

asadmshah
asadmshah

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

Duncan Hoggan
Duncan Hoggan

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

Jagadesh Seeram
Jagadesh Seeram

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

Related Questions