2016-10-11 212 views
0

因此,我遇到了一個問題,我無法找到解決方案。我做了一個小問題的剪輯。 Video滾動時更改collapsingToolbarLayout的顏色

我想要的是,只要我滾動collapsingToolbarLayout顏色應該開始改變爲工具欄顏色,因爲它發生在Facebook應用程序中。正如你所看到的,當它覆蓋了collapsingToolbarLayout的3/4高度時開始。

XML:

<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar_layout" 
    android:layout_width="match_parent" 
    android:layout_height="280dp" 
    android:fitsSystemWindows="true" 
    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" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:expandedTitleMarginEnd="56dp" 
     app:expandedTitleMarginStart="24dp" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     app:titleEnabled="true"> 


     <RelativeLayout 
      android:id="@+id/layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:id="@+id/imageV" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:adjustViewBounds="true" 
       android:contentDescription="@null" 
       android:fitsSystemWindows="true" 
       android:scaleType="centerCrop" 
       android:transitionName="image" 
       app:layout_collapseMode="parallax" 
       tools:targetApi="lollipop" /> 

      <View 
       android:id="@+id/view" 
       android:layout_width="match_parent" 
       android:layout_height="280dp" 
       android:background="#200000" /> 

     </RelativeLayout> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar1" 
      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> 

得到任何幫助。謝謝。

回答

0

CollapsingToolbarLayout具有稱爲app:scrimVisibleHeightTrigger

一個屬性指定用於定義何時觸發稀鬆布能見度變化可見高度的以像素爲單位的量。

由於您的應用欄的高度爲280dp,因此設置app:scrimVisibleHeightTrigger="240dp"應該可以工作。

我不記得那是從頂部還是從底部,所以如果這使得改變真的很晚,請嘗試app:scrimVisibleHeightTrigger="20dp"。無論如何,你應該能夠調整這個價值來獲得你想要的外觀。