I have a question about Android app bar, tool bar, and collapse mode.

Asked 1 years ago, Updated 1 years ago, 92 views

If you scroll through the Recycler view from the view above, I want to make the toolbar text above and the text view below disappear.

<android.support.design.widget.AppBarLayout
    android:id="@+id/study_app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

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

        <android.support.v7.widget.Toolbar
            android:id="@+id/study_tool_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_collapseMode="parallax"
            >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >

                <TextView
                    android:id="@+id/study_tool_bar_title_txt"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:paddingTop="5dp"
                    android:text="@string/app_name"
                    android:textColor="#ffffff"
                    android:textSize="20sp"
                    android:textStyle="bold"
                    />


                <TextView
                    android:id="@+id/introduce_app_txt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginLeft="1dp"
                    android:layout_marginRight="17dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/rectangle_back"
                    android:elevation="2dp"
                    android:text="@string/introduce_app_txt"
                    android:textColor="#ffffff"/>

            </LinearLayout>
        </android.support.v7.widget.Toolbar>

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

<android.support.v7.widget.RecyclerView
    android:id="@+id/study_tab_recycler"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/study_app_bar"
    android:layout_marginTop="2dp"
    android:layout_marginBottom="90dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

</android.support.v7.widget.RecyclerView>

I tried to put collphaseMode in several views, but the toolbar doesn't go up.(Crying) Does anyone know?

android toolbar collapsemode app-bar

2022-09-21 16:01

1 Answers

I googled a little bit and there's an example. Please refer to it ^ https://mzgreen.github.io/2015/02/15/How-to-hideshow-Toolbar-when-list-is-scroling%28part1%29/

^


2022-09-21 16:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.