小编Jam*_*Jam的帖子

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>
Run Code Online (Sandbox Code Playgroud)

我认为当毕加索将图像加载到ImageView中时,它可能会请求Focus和requestLayout,而CoordinatorLayout在这种情况下无法正确地重绘工具栏,但这只是我的猜测.

任何建议都会有所帮助,非常感谢!

android android-toolbar android-design-library

18
推荐指数
1
解决办法
2575
查看次数