您的位置:首页 > Web前端

What is the difference between addView and addViewInLayout?

2015-12-17 16:21 651 查看
转自stackoverflow

Its generally a bad idea to call
addView
inside
onLayout
because
addView
internally
triggers a
requestLayout
which
eventually will call
onLayout
.
So you end up triggering a layout while you are in the middle of a layout.

addViewInLayout
is
a "safer" version of the
addView
in
the case you really have to add a new view in
onLayout
.
It basically doesn't trigger a layout pass (doesn't call requestLayout internally).

See this video (by android engineer) for more detail: http://www.youtube.com/watch?v=HbAeTGoKG6k

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: