Collapsingtoolbarlayout change and leave transparent

Asked

Viewed 274 times

2

I can’t change the color of Collapsingtoolbarlayout When I roll it up it gets the image I put in and doesn’t change the color.

Before:

CollapsingToolbarLayout Normal

Afterward:

CollapsingToolbarLayout depois

I wanted to take the image and make Toolbar transparent.

  • Ask the question what xml you are using .

  • 1

    Can you show us how you did it? Help people help you! =)

1 answer

1


You can add the contentScrim at the CollapsingToolbarLayout and make the bottom of the toolbar transparent, but with opacity, or if you prefer with a solid color. Since you didn’t put any code, it would be something in this format:

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

A GIF is worth a thousand images

inserir a descrição da imagem aqui

As shown in the image above, the color of Toolbar is solid. To be transparent, simply change the value of contentScreem for a color that has opacity. For example app:contentScrim="#77000000". See the image below:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.