18

I am using the new design support library to achieve scroll to hide toolbar. However, every thing works well if I don't load images by picasso. If I load images, sometimes when I scroll down to let toolbar show again, my toolbar become a blank white rectangle. Note that in this situation I still can press the navigation toggle to open the drawer, although it is not draw(show) on the screen:

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

But sometimes it works well:

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

I am so confusing about this, if I disable all loading image task, the toolbar can be shown properly. Here is my layout:

<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>

I think when picasso load image into ImageView, it may requestFocus and requestLayout and the CoordinatorLayout can't redraw the toolbar properly in that situation but It is only my guess.

Any suggestion will help, many thanks!

2
  • I also faced same kind of problem. can't figure it out. Any help will be appreciable ....
    – Sayem
    Commented Jun 8, 2015 at 5:25
  • Looks like it only happened below 5.1
    – CzBiX
    Commented Jun 23, 2015 at 7:06

1 Answer 1

11
<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>

Try this. I solved same problem by this snippet. I appended dummy view which has height of 1dp after the Toolbar.

3
  • Can you explained what's this problem?
    – CzBiX
    Commented Jun 23, 2015 at 4:39
  • It is a bug. See this link Commented Jun 23, 2015 at 5:55
  • WTF Google? The bug still exists 1 year later.
    – 0101100101
    Commented May 6, 2016 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.