现在的位置: 首页 > 综合 > 正文

removeAllViews()和removeAllViewsInLayout()的区别

2018年01月18日 ⁄ 综合 ⁄ 共 405字 ⁄ 字号 评论关闭

在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()移除不掉,因为子视图还未计算。

抱歉!评论已关闭.