Android Studio XML using marginRight with API 17

I have a RelativeLayout and I am using android:layout_marginEnd="170dp" and Android Studio is telling me:

To support older version than API 17(project specifies 15) you should also add

android:layout_marginRight="170dp"

It's not an error, it compiles correctly, but I don't understand this hint. Why should I use marginRight? Why not marginLeft? Can anyone explain me the secret behind this? I looked for other answers but I still didn't get it.

Thank you in advance.

1 answer

  • answered 2017-06-17 18:19 Sean Barbeau

    android:layout_marginEnd was added in API 17 for better support for right-to-left languages. However, earlier versions of Android prior to API 17 don't recognize this tag, so your need to add android:layout_marginRight as well.