Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A MATCH_PARENT view inside a WRAP_CONTENT view

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?

like image 974
Chin Avatar asked Mar 16 '14 15:03

Chin


People also ask

What is the difference between Match_parent and Wrap_content?

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.

What is Wrap_content and Match_parent in Android Studio?

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.


1 Answers

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.

like image 123
Alqueraf Avatar answered Nov 15 '22 16:11

Alqueraf