Reputation: 584
As far as I've understood Android's View rendering process, the root Layout will start the measurement and ask each of its children for it's size. If one of them is a Viewgroup itself, it will again ask the children, which either just return their set size, or calculate it if they're set to wrap_content
.
Now how does that work with match_parent
? The view can't calculate it's size since it has to know the parent's size first, right? So the parent would have to calculate it's own size and then send that to the child, which then can go on with it's own layout.
Does that make match_parent
a little more inefficient than wrap_content
or even fixed dp-values?
Upvotes: 0
Views: 98
Reputation: 3340
Actually, match_parent
says that "Hi parent, I want to be as big as your left available space".For example, if ViewGroup Parent has two children: child A at index 0 with wrap_content
and child B at index 1 with match_parent
. And A says he wants to be 100px wide, then the width of B will be : total width of Parent - padding of Parent - margin of A - 100px - margin of B
Upvotes: 1