Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Monday, June 11, 2012
Difference between a View"s Padding and Margin
What is the difference between a View's Margin and Padding?
Padding is the space inside the border, between the border and the actual view's content. Note that padding goes completely around the content: there is padding on the top, bottom, right and left sides (which can be independent).
Margins are the spaces outside the border, between the border and the other elements next to this view. In the image, the margin is the grey area outside the entire object. Note that, like the padding, the margin goes completely around the content: there are margins on the top, bottom, right, and left sides.
Padding is within the view, margin is outside. Padding is available for all views. Depending on the view, there may or may not be a visual difference between padding and margin.
Whether or not margin is available, on the other hand, is determined by the container of the view, not by the view itself. In LinearLayout margin is supported, in AbsoluteLayout - no.
Padding is the space inside the border, between the border and the actual view's content. Note that padding goes completely around the content: there is padding on the top, bottom, right and left sides (which can be independent).
ReplyDeleteMargins are the spaces outside the border, between the border and the other elements next to this view. In the image, the margin is the grey area outside the entire object. Note that, like the padding, the margin goes completely around the content: there are margins on the top, bottom, right, and left sides.
An image says more than 1000 words:
Padding is inside of a View.
ReplyDeleteMargin is outside of a View.
This difference may be relevant to background or size properties.
Padding is within the view, margin is outside. Padding is available for all views. Depending on the view, there may or may not be a visual difference between padding and margin.
ReplyDeleteWhether or not margin is available, on the other hand, is determined by the container of the view, not by the view itself. In LinearLayout margin is supported, in AbsoluteLayout - no.
This may be helpful
ReplyDeleteDeclaring Layout