Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android's box model

Rather surprised that I haven't been able to found detailed information about Android's box model. I mean how padding, margins, gravities, etc. they all interact together.

Other than this note about margin and padding in the dev site and this SO question there's not much information out there.

What I'm looking for:

  • What are the defaults for margins, paddings, gravities, etc.
  • Can manufacturers alter those defaults. If so, is it a good practice ignoring those defaults so your app looks consistent across different manufacturers?
  • How are conflicts resolved, specially between a component and its children.
  • Any difference between Android versions?

Is it really that simple that is not worth a deeper explanation in the docs?

Thanks,

Juan

like image 391
Juan Delgado Avatar asked Jun 24 '11 14:06

Juan Delgado


1 Answers

Rather surprised that I haven't been able to found detailed information about Android's box model.

Note that little in your question has anything to do with LinearLayout, the Android equivalent of the "box model" found in XUL or Flex. Perhaps you have a different definition of "box model" than I use.

What are the defaults for margins, paddings, gravities, etc.

0 pixels for the default margin and padding. Default gravity varies by widget/container.

Can manufacturers alter those defaults.

Technically, yes, though I am not aware of this being done in practice.

How are conflicts resolved, specially between a component and its children.

There are no possible conflicts in margin, padding, or gravity.

Any difference between Android versions?

Not that I am aware of.

Is it really that simple that is not worth a deeper explanation in the docs?

IMHO, yes.

like image 168
CommonsWare Avatar answered Sep 27 '22 20:09

CommonsWare