Title in Scrolling Activity

Asked

Viewed 89 times

0

Hello, I’m having a problem in the scrolling Activity. I would like to hide the title when the appbar is fully stretched and when retracted, the title is visible again. This is possible?

my xml:

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/app_bar_height"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:toolbarId="@+id/toolbar">

        <android.support.constraint.ConstraintLayout
            android:id="@+id/scrolling"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/imgBackground"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:scaleType="centerCrop"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/background_scrolling" />
        </android.support.constraint.ConstraintLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:layout_collapseParallaxMultiplier="1.0"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_treinos" />

inserir a descrição da imagem aqui

1 answer

0

Look at this tutorial

Toolbar Animation with Android Design

At the end there is the Activity code, where it shows that there is a system in appear, when it is expanded you clear the text

collapsingToolbar.setTitle(""); 

And when reduce shows the text

collapsingToolbar.setTitle("Texto");

Browser other questions tagged

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