问题描述
我公司采用新的设计支持库,实现滚动隐藏工具栏。然而,每一件事情效果很好,如果我不被毕加索加载图像。如果我加载图像,有时当我向下滚动,让工具栏再次显示,我的工具栏变成了空白的白色矩形。请注意,在这种情况下我仍然能preSS的导航键打开抽屉,虽然不能得出(显示)在屏幕上:
<一个href="https://www.dropbox.com/s/nte3pr091nt2wfx/device-2015-05-30-093222.png?dl=0">https://www.dropbox.com/s/nte3pr091nt2wfx/device-2015-05-30-093222.png?dl=0
但有时它工作得很好:
<一个href="https://www.dropbox.com/s/i3u87df4x48fhj6/device-2015-05-30-094217.png?dl=0">https://www.dropbox.com/s/i3u87df4x48fhj6/device-2015-05-30-094217.png?dl=0
我很困惑这事,如果我禁用所有加载图像的任务,工具栏可以正常显示。这是我的布局:
&LT; android.support.design.widget.CoordinatorLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent&GT;
&LT; android.support.design.widget.AppBarLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT&GT;
&LT; android.support.v7.widget.Toolbar
机器人:ID =@ + ID /工具栏
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
机器人:ATTR / colorPrimary后台=
应用程序:layout_scrollFlags =滚动| enterAlways/&GT;
&LT; /android.support.design.widget.AppBarLayout>
&LT;的FrameLayout
机器人:ID =@ + ID /主
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用程序:layout_behavior =@字符串/ appbar_scrolling_view_behavior/&GT;
&LT; /android.support.design.widget.CoordinatorLayout>
我认为当毕加索负荷的形象成ImageView的,它可能不是requestFocus和requestLayout和CoordinatorLayout不能重新绘制工具栏中适当在这种情况下,但是这仅仅是我的猜测。
任何建议将帮助,非常感谢!
&LT; android.support.design.widget.CoordinatorLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent&GT;
&LT; android.support.design.widget.AppBarLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT&GT;
&LT; android.support.v7.widget.Toolbar
机器人:ID =@ + ID /工具栏
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
机器人:ATTR / colorPrimary后台=
应用程序:layout_scrollFlags =滚动| enterAlways/&GT;
&LT;查看
机器人:layout_width =FILL_PARENT
机器人:layout_height =1DP/&GT;
&LT; /android.support.design.widget.AppBarLayout>
&LT;的FrameLayout
机器人:ID =@ + ID /主
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用程序:layout_behavior =@字符串/ appbar_scrolling_view_behavior/&GT;
&LT; /android.support.design.widget.CoordinatorLayout>
试试这个。我用这个片段解决了同样的问题。我附加有工具栏后1DP的高度虚拟视图。
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!
<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.
这篇关于CoordinatorLayout(AppbarLayout)不绘制工具栏正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!