I understand that MATCH_PARENT
means that the View wants to be as big as its parent (minus padding), and WRAP_CONTENT
means that the View wants to be just big enough to enclose its content (plus padding)
My question is, what happens when a MATCH_PARENT
view (view A) is put inside a WRAP_CONTENT
view (view B)? How are the parameters of the two views A and B calculated in this case?
For each dimension, it can specify one of: FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding) WRAP_CONTENT, which means that the view wants to be just big enough to enclose its content (plus padding) an exact number.
fill_parent and match_parent are the same, used when we want the height or width of a view to be as big as its parent view, fill_parent being deprecated. wrap_content is used when we want the view to occupy only as much space as required by it.
It fills all the space possible allowed for its parents, looking up on the hierarchy.
If the parent of the WRAP_CONTENT view (View B) has a size limit, it will take that size.
If no hierarchical parent has size (all are wrap_content until the root view) it will take up the whole screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With