What is the difference between marginStart / marginLeft and marginEnd / marginRight?

1

I know this is a fairly simple question, but I have already tried it and still have not found a satisfactory answer. After all, is marginLeft not equivalent to marginStart ? And would not it be the same for marginEnd and marginRight ? Could anyone explain the difference between these XML android properties?

    
asked by anonymous 21.12.2016 / 19:30

1 answer

5

The big difference between them is only perceived on devices using some language that requires RTL (Right to Left) and not LTR (Left to Right) as we are accustomed.

You can force this view using the developer settings, but it is not very common to use this.

RTL support only appeared completely on Android 4.2, but already had basic support on Android 4.1, that post can help you understand.

Returning the question, marginStart and marginEnd , as well as paddingStart and paddingEnd will generate the same result if the device is in LTR than its fixed attributes: marginLeft , marginRight paddingLeft and paddingRight respectively, but if the device is in RTL it will be just the opposite.

When you use marginLeft , you are applying the left (fixed) margin of the element in the LTR view. If you use marginStart , this margin applies to the (relative) start. In the case of the LTR view is the left of the element, but in the case of the RLT is the right of the element.

My suggestion is to always use the relative attributes if your minSdkVersion is greater than 17 (Android 4.2). If your% w of% is less than 17, always use the two together with the same values. e.g. minSdkVersion and marginLeft .

    
21.12.2016 / 20:49