Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Set a different padding for each direction using a single statement

In CSS, one can set a different padding for top, right, bottom and left using the following, 1 line statement:

padding: 5px,10px,15px,5px;

I was wondering if there is a way to do the same while implementing a layout in Android XML. Currently, to achieve the same result (using dp instead of px), I do it this way:

android:paddingTop="5dp";
android:paddingRight="10dp";
android:paddingBottom="15dp";
android:paddingLeft="5dp";

So, is there a way to do the above in a single statement? For example:

android:padding="5dp,10dp,15dp,5dp";
like image 288
Ziad Akiki Avatar asked Oct 26 '25 00:10

Ziad Akiki


1 Answers

Yes but you cannot do that in XML but you can do it in your java code

btn_submit.setPadding(5,10,7,8);
like image 56
RAHUL MAURYA Avatar answered Oct 28 '25 17:10

RAHUL MAURYA



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!