removeAllViews()和removeAllViewsInLayout()的区别

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

void removeAllViews()
Call this method to remove all child views from the ViewGroup.从ViewGroup中移除所有子视图
void removeAllViewsInLayout()
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()移除不掉,因为子视图还未计算。

你可能感兴趣的:(android)