Try creating a custom View or ViewGroup and you will find out.
There's 3 stages on bringing a View to your screen:
In measure the parent tells the child how much space is available. It may do that in respect to the childs layout parameters. So if the child says match_parent
(fill_parent
is deprecated) the parent will pass in either its own size, or the remaining space (most of the time...)
The child then takes the available size, calls setMeasuredDimenstion(allTheSpaceIGot)
and that's measuring for you.
Next up during layout, the parent checks the childrens measured sizes. It then sets the childrens bounds (top, left, bottom, right) accordingly.
Finally in onDraw every child draws itself within its bounds.
To sum this up:
- Child gives parent information about its wishes.
- Parent offers child some available space.
- Child says "I'll take it".
- Parent gives child its final restraints
- Child draws itself within the constraints
If you want to assign say 60% to a view you should have a look at creating a custom ViewGroup (since that is who actually decides on the childs dimensions)
I also wrote a blog post about custom views that goes into more detail, followed by how to create a custom layout.