2015-05-30 36 views
18

我正在使用新的設計支持庫來實現滾動以隱藏工具欄。 然而,如果我沒有加載圖像的畢加索,每件事情都很好。如果我加載圖像,有時當我向下滾動以讓工具欄再次顯示時,我的工具欄變成空白的白色矩形。請注意,在這種情況下,我仍然可以按導航鍵打開抽屜,雖然不能得出(顯示)在屏幕上:CoordinatorLayout(AppbarLayout)不能正確繪製工具條

https://www.dropbox.com/s/nte3pr091nt2wfx/device-2015-05-30-093222.png?dl=0

但有時它工作得很好:

https://www.dropbox.com/s/i3u87df4x48fhj6/device-2015-05-30-094217.png?dl=0

我很困惑這個,如果我禁用所有的加載圖像任務,工具欄可以正確顯示。 這裏是我的佈局:

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" /> 

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

    <FrameLayout 
     android:id="@+id/main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

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

我認爲,當畢加索負荷的形象爲ImageView的,它可能requestFocus的和requestLayout和CoordinatorLayout不能正常在這種情況下重繪工具欄,但它只是我的猜測。

任何建議都會有所幫助,非常感謝!

+0

我也面臨同樣的問題。無法弄清楚。任何幫助將是可觀的... – Sayem

+0

看起來像它只發生在5.1 – CzBiX

回答

10
<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|enterAlways" /> 

     <View 
     android:layout_width="fill_parent" 
     android:layout_height="1dp"/> 

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

    <FrameLayout 
     android:id="@+id/main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

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

試試這個。我通過這個片段解決了同樣的問題。我在工具欄後添加了具有1dp高度的虛擬視圖。

+0

你能解釋這是什麼問題? – CzBiX

+0

這是一個錯誤。請參閱此鏈接(http://stackoverflow.com/questions/30540648/new-android-design-library-bug-with-appbarlayout-and-toolbar) – neosarchizo

+0

WTF Google?該錯誤在1年後仍然存在。 – 0101100101

相關問題