Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

paddingStart/Left and paddingEnd/Right

Tags:

android

xml

In recent code writing times I've seen a single element contain only paddingLeft/Right, only paddingStart/End, and both.

Can't seem to find anything on which is better and why. anybody have any insight / when to use one or the other or both?

like image 434
1tSurge Avatar asked Sep 12 '16 19:09

1tSurge


Video Answer


1 Answers

You need the new start/end properties to create a nice Right-To-Left layout, used in countrys where people read from right to left.

There is no better version, just a newer version.

If you want to support Android versions prior to Android 4.2, you should use the old and the new properties together. If you only want to support Android 4.2 and newer versions, it's ok to only use the new properties paddingStart (instead of paddingLeft).

There is a nice explanation available on the Android Developers Blog:

To take advantage of RTL layout mirroring, simply make the following changes to your app:

  1. Declare in your app manifest that your app supports RTL mirroring.

    • Specifically, add android:supportsRtl="true" to the element in your manifest file.
  2. Change all of your app's "left/right" layout properties to new "start/end" equivalents.

    • If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use “start” and “end” instead of “left” and “right”. For example, android:paddingLeft should become android:paddingStart.

    • If you want your app to work with versions earlier than Android 4.2 (the app's targetSdkVersion or minSdkVersion is 16 or less), then you should add “start” and end” in addition to “left” and “right”. For example, you’d use both android:paddingLeft and android:paddingStart.

like image 138
Loki C. Avatar answered Oct 29 '22 12:10

Loki C.