question

njsokalski avatar image
0 Votes"
njsokalski asked RobCaplan edited

PaddingStart/PaddingEnd vs PaddingLeft/PaddingRight: Which One Should I Use?

PaddingStart & PaddingEnd seem to serve the same purpose as PaddingLeft & PaddingRight. Is there a difference between the two? In my case, I am using them with a TextView. At the moment, I have my code working with PaddingStart & PaddingEnd, but it sometimes worries me as to whether there may be a scenario in the future where they do not do the same thing. Also, I want to make sure I am consistent in which one I use. If I use PaddingStart & PaddingEnd, will a value be assigned to PaddingLeft & PaddingRight (and vice versa)? What happens if I assign values to both? I know that the values for PaddingStart & PaddingEnd are affected by the RTL settings (which I never use). I am also aware of PaddingHorizontal. All these different ways of specifying values that sound the same is sometimes confusing. My 2 main questions are:
Does assigning values to one affect the values of the others?
Which one takes priority if values are assigned to both?
If anyone knows of any good tutorials or blogs on the comparison of these properties, I would like to know about it. Thanks.

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered JarvanZhang-MSFT commented

Hello,​

Welcome to our Microsoft Q&A platform!

Which one takes priority if values are assigned to both?

The value of PaddingStart & PaddingEnd will take precedence over PaddingLeft & PaddingRight.

Does assigning values to one affect the values of the others?

PaddingLeft property are used to set the left/right padding of this view, PaddingStart is not only suitable for left padding. The device has LTR and RTL modes. If the user is in a locale that writes from right to left (RTL), then PaddingStart will be applied on the right side, while if they're in a left-to-right (LTR) locale (such as English), it will be applied on the left side. PaddingStart will always be applied on the left, regardless of the locale's text direction.

Best Regards,

Jarvan Zhang



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for that information! But what about priority of PaddingHorizontal? Also, is one recommended or more commonly used than the others in scenarios where they will (supposedly) have the same effect (for example, if PaddingLeft & PaddingRight have the same value)?

0 Votes 0 ·

PaddingHorizontal sets the padding of the left and right edges. This value will take precedence over PaddingLeft and PaddingRight, but not PaddingStart or PaddingEnd (if set).

Check the doc: https://developer.android.com/reference/android/R.attr#paddingHorizontal

0 Votes 0 ·