Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Effects of Negative padding

I'm just starting to learn android and i had a question regarding negative padding. How exactly does negative padding affect the view ?

Also, say I introduce a bottomPadding of "-5dp". Does this extend of the boundary of the padding by 5dp ?

All help appreciated! :)

like image 698
Traxex1909 Avatar asked Jun 26 '13 06:06

Traxex1909


People also ask

What is the effect of using a negative number in a padding declaration?

Padding only takes positive values. Negatives are ignored or treated as 0, which would have the same effect: none.

Is it bad to use negative margins in CSS?

The downside of negative margins is they are difficult to debug and will make your CSS harder to read. The most often misuses of negative margins that I encounter is when it is used to make up for incorrect layouts elsewhere on the site. This is indeed bad practice.

Is it good practice to use negative margins?

Using negative margin is considered bad practice as it makes the code more complex and difficult for developer's understanding. Generally there is no need to use negative margin, unless and until you have made any error elsewhere.

What do negative margins do?

It is possible to give margins a negative value. This allows you to draw the element closer to its top or left neighbour, or draw its right and bottom neighbour closer to it.


1 Answers

In LinearLayout and RelativeLayout after setting negative padding you will notice movement of the content into opposite direction - for example if you set paddingLeft to -5dp, it will be moved to the left side by 5dp, whereas setting it to 5dp would cause content to be moved into right position.

like image 75
Piotr Chojnacki Avatar answered Nov 12 '22 07:11

Piotr Chojnacki