2017-04-19 79 views
0

我的CollapsingToolbarLayout工作不夠準確。圖1顯示了當我向下滾動一點時的初始狀態和圖像2。過渡發生得太早,最終會出現在(在這種情況下)粉紅色的空白區域。再次滾動時會發生同樣的情況。 有什麼辦法解決這個問題?CollapsingToolbarLayout /工具欄過早/過時淡化

我的佈局:

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/activity_main_cover_height" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

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

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <ImageView 
       android:id="@+id/backdrop" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:scaleType="centerCrop" 
       app:layout_collapseMode="parallax" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:background="@color/transparent_background_dark" 
       android:orientation="vertical" 
       android:paddingLeft="@dimen/box_headline_padding" 
       android:paddingStart="@dimen/box_headline_padding"> 

       <!-- ... --> 

      </LinearLayout> 

     </RelativeLayout> 

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

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

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

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="0dp" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <!-- ... --> 
</android.support.v4.widget.NestedScrollView> 

enter image description hereenter image description here

回答

1

感謝when the morning來我想通了正確的參數app:scrimVisibleHeightTrigger在 我結合這兩種

app:scrimAnimationDuration="300" 
app:scrimVisibleHeightTrigger="60dp" 
的 結束
1

使用該屬性在CollapsingToolbarLayout:

 app:scrimAnimationDuration="600" 

的時間以毫秒爲單位。

相關問題