3

我有一個CollapsingToolbarLayout與背景中的視差圖像,我已經設置了程序化的網格顏色,我想摺疊工具欄,當我開始活動,如果沒有圖像顯示背景,所以在活動開始我檢查是否沒有圖像,然後我在AppBarLayout上調用setExpanded(false,false),但它需要大約2秒來顯示稀鬆布顏色,我需要調用任何方法來強制它顯示稀鬆平常顏色活動創造?或者是否有任何其他解決方法來強制這種稀鬆平衡色顯示在創建?Android AppBarLayout摺疊工具欄和顯示平鋪顏色沒有延遲

這是我的佈局資源:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 
    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="270dp"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:id="@+id/image" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       app:layout_collapseMode="parallax" /> 
      <include layout="@layout/toolbar"/> 

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

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

    <include layout="@layout/content" /> 
</android.support.design.widget.CoordinatorLayout> 

回答

0

我找到了一種方法來解決這個問題:崩潰方法後,就在CollapsingToolbarLayout調用setScrimsShown(真,假)