does adding a child to a ViewGroup (via ViewGroup.addView() ) automatically invoke onMeasure() for all childs?
Asked
Active
Viewed 1,143 times
3
-
Could you not try it by doing some logging or by using break points? – Automatico Apr 04 '13 at 13:50
1 Answers
2
ViewGroup
should measure it's width and height by first measuring all children. If ViewGroup
's width or height is wrap_content it will call onMeasure()
for all children for sure. Can't say that about match_parent. One thing for sure that addView()
calls requestLayout()
which will re-calculate layout children's position call layout(l, t, r, b)
on all children.
To know for sure if it calls you can create a custom View
and log every call to onMeasure()
and add those to a ViewGroup
. Could be that different ViewGroup
implementation will act differently.

Yaroslav Mytkalyk
- 16,950
- 10
- 72
- 99