removeAllViews()和removeAllViewsInLayout()的区别

来源:互联网 发布:js click与onclick 编辑:程序博客网 时间:2024/05/01 00:59

在ViewGroup类中,有这两个方法:
voidremoveAllViews()

Call this method to remove all child views from the ViewGroup.从ViewGroup中移除所有子视图
voidremoveAllViewsInLayout()
Called by a ViewGroup subclass to remove child views from itself, 
when it must first know its size on screen before it can calculate how many child views it will render.
ViewGroup的子类调用,移除自身的子视图,但在它能计算多少子视图被渲染前,必须首先知道它在屏幕中尺寸。
所以在有些情况下,removeAllViews()能移除掉子视图,但removeAllviewsInLayout()移除不掉,因为子视图还未计算。

0 0
原创粉丝点击