簡體   English   中英

CoordinatorLayout(AppbarLayout)無法正確繪制工具欄

[英]CoordinatorLayout(AppbarLayout) does not draw toolbar properly

我正在使用新的設計支持庫來實現滾動隱藏工具欄。 但是,如果我不加載畢加索的圖像,那么每件事都很有效。 如果我加載圖像,有時當我向下滾動以再次顯示工具欄時,我的工具欄將變成一個空白的白色矩形。 請注意,在這種情況下,我仍然可以按導航切換打開抽屜,雖然它不是在屏幕上繪制(顯示):

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中時,它可能會請求Focus和requestLayout,而CoordinatorLayout在這種情況下無法正確地重繪工具欄,但這只是我的猜測。

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

<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的虛擬視圖。

暫無
暫無

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

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