简体   繁体   中英

custom scroll behavior is never called in toolbar app:layout_behavior

I am trying to get toolbar background change when scroll up or down. for that i used the following custom behavior extends from CoordinatorLayout.Behavior<android.support.v7.widget.Toolbar> and call this custom behavior in toolbar layout

    <android.support.design.widget.AppBarLayout
       .......
        android:fitsSystemWindows="true"
        android:background="@android:color/transparent"
        android:theme="@style/AppTheme.AppBarOverlay">

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

        <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_behavior=".components.ToolbarAlphaScrollBehavior"/> // this is my custom behavoir
</android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>
    <FrameLayout
        android:id="@+id/content_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </FrameLayout>
    </android.support.design.widget.CoordinatorLayout>

the problem here is that this custom behaviour is never called.

进行一个新的Activity并将其设置为Scroll Activity而不是Blank Activity(如果您只是开始并且没有编写太多代码)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM