android – Differences between Padding and Margin


What is the difference of using Padding and Margin in an Android view?

When should I know which one to use?


The main difference is that:

  • padding reserves space for the element;
  • the margin just defines the spacing and projects the element itself or one with which it has contact.

That is, if you apply background to an element that has padding defined, the space relative to the padding will receive color, while the same element with the margin applied in place of the padding will not receive color in the area corresponding to the margin .

You can find more information on thisquestion here .

Scroll to Top