Android Toolbar collapseMode issue

前端 未结 2 1567
悲哀的现实
悲哀的现实 2020-12-16 02:23

I have an Issue making \" toolbar with Title text \" Not to Collapse while scrolling upwards in CollapsingToolbarLayout.

I have tried a few tweaks, by using

相关标签:
2条回答
  • 2020-12-16 02:30

    In your toolbar do this:

    app:layout_collapseMode="pin"
    

    pin is used for pinning the layout to top when the collapsing toolbar layout scrolls

    parallax is used for hiding the layout when collapsing toolbar scrolls to top

    0 讨论(0)
  • 2020-12-16 02:33

    try this...

    You have to use app:layout_scrollFlags="scroll|exitUntilCollapsed" instead of app:layout_scrollFlags="scroll|enterAlways" inside the CollapsingToolbarLayout

    and use app:layout_collapseMode="pin" inside the toolbar

    <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary" >
    
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="250dp"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7" >
    
                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop" />
    
                <View
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#20000000" />
            </FrameLayout>
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Application Title"
                    android:textColor="#fff"
                    android:textSize="18sp" />
            </android.support.v7.widget.Toolbar>
    
        </android.support.design.widget.CollapsingToolbarLayout>
    
    0 讨论(0)
提交回复
热议问题