簡體   English   中英

在工具欄應用程序中永遠不會調用自定義滾動行為:layout_behavior

[英]custom scroll behavior is never called in toolbar app:layout_behavior

我試圖上下滾動時更改工具欄背景。 為此,我使用以下自定義行為從CoordinatorLayout.Behavior<android.support.v7.widget.Toolbar>擴展並在工具欄布局中調用此自定義行為

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

這里的問題是,從未調用此自定義行為。

進行一個新的Activity並將其設置為Scroll Activity而不是Blank Activity(如果您只是開始並且沒有編寫太多代碼)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM