Based on the Android document which doesn't give much explanation, what's the difference between setPadding()
vs setPaddingRelative()
?
So when you set padding with setPaddingRelative it changes left and right padding values depending on user's layout direction. Follow this answer to receive notifications.
Use the setPadding(left, top, right, bottom) method on the view to set the padding. The integers passed as parameters to this function are the number of pixels (px), which are different from the density-independent pixels (dp or dip).
setPaddingRelative
has this code inside:
switch(getResolvedLayoutDirection()) { case LAYOUT_DIRECTION_RTL: setPadding(end, top, start, bottom); break; case LAYOUT_DIRECTION_LTR: default: setPadding(start, top, end, bottom); }
So when you set padding with setPaddingRelative
it changes left and right padding values depending on user's layout direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With