postInvalidate 解决View.GONE,没有刷新的问题

问题描述:
布局:

<ScrollView id="scroll">
<LinearLayout id="container">
       <LinearLayout  id="child1">

</LinearLayout>
       <LinearLayout  id="child2">

</LinearLayout>
      <LinearLayout  id="child3">

</LinearLayout>

</LinearLayout>
</ScrollView>

当 id="child3" View.GONE 时,child2会自动移到最顶部,并且全屏显示出来,但是child3还在,其实已不在了,只是没有刷新过来。

尝试1:
container.requestLayout();
container.postInvalidate();
不行。
尝试2:
child3.clearAnimation();

不行。


尝试3:

scroll.postInvalidate();

  成功。

  

猜你喜欢

转载自www.cnblogs.com/jiduoduo/p/12356540.html