Sizdian
Sizdian

Reputation: 79

Android Relative Layout alignParentRight and alignParentEnd

I'm trying to figure out the difference between the layout params for relative layout, specifically alignParentRight and alignParentEnd (also alignParentLeft and alignParentStart). Reading the reference doesn't help much, I figured the end of a parent was always its right. Is there any difference to this? Is one depreciated now?

Upvotes: 5

Views: 4748

Answers (3)

kenju
kenju

Reputation: 5954

Let me add 1 more point beside @CommonsWare's answer. Please be aware that alignStart, alignEnd and alignParentEnd, alignParentStart were added in API Level 17, so that you cannot use those attributes before 17.

https://developer.android.com/reference/android/R.attr.html#layout_alignParentEnd

╔═══════════════════════════════════╦═══════════════════════╗
║ API Level 1                       ║ API Level 17          ║
╠═══════════════════════════════════╬═══════════════════════╣
║ alignBaseLine                     ║ align(Start/End)      ║
║ alignWithParentIfMissing          ║ alignParent(Start/End)║
║ align(Top/Bottom/Left/Right)      ║                       ║
║ alignParent(Top/Bottom/Left/Right)║                       ║
╚═══════════════════════════════════╩═══════════════════════╝

Upvotes: 3

AndroidEx
AndroidEx

Reputation: 15824

alignParentEnd and alignParentStart are used in RTL (right-to-left) layouts in countries where this is a historical norm. In this case "end" actually becomes "left" instead of "right". If you provide all your views with these attributes, your layout will look like horizontally flipped in RTL layouts, which is more convenient for users in these countries.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006769

I figured the end of a parent was always its right

Only for left-to-right (LTR) languages. For right-to-left (RTL) languages (e.g., Hebrew, Arabic), end is left and start is right. If you use end and start attributes, your layout will mirror when it is run on a device set to an RTL locale. If you use left and right, it will not mirror.

Upvotes: 9

Related Questions