阅读 Android 源代码 (View.java) 后,似乎 paddingStart 和 paddingEnd 有助于处理用户定义的字母方向(从左到右,从右到左)。
因此,paddingStart 在 LTR(从左到右)语言中被解释为 paddingLeft,在 RTL(从右到左)语言中被解释为 paddingRight。
来自 View.java (android-4.0.1) 的源代码:
switch (getResolvedLayoutDirection()) {
case LAYOUT_DIRECTION_RTL:
// Start user padding override Right user padding. Otherwise, if Right user
// padding is not defined, use the default Right padding. If Right user padding
// is defined, just use it.
if (mUserPaddingStart >= 0) {
mUserPaddingRight = mUserPaddingStart;
} else if (mUserPaddingRight < 0) {
mUserPaddingRight = mPaddingRight;
}
if (mUserPaddingEnd >= 0) {
mUserPaddingLeft = mUserPaddingEnd;
} else if (mUserPaddingLeft < 0) {
mUserPaddingLeft = mPaddingLeft;
}
break;
case LAYOUT_DIRECTION_LTR:
default:
// Start user padding override Left user padding. Otherwise, if Left user
// padding is not defined, use the default left padding. If Left user padding
// is defined, just use it.
if (mUserPaddingStart >= 0) {
mUserPaddingLeft = mUserPaddingStart;
} else if (mUserPaddingLeft < 0) {
mUserPaddingLeft = mPaddingLeft;
}
if (mUserPaddingEnd >= 0) {
mUserPaddingRight = mUserPaddingEnd;
} else if (mUserPaddingRight < 0) {
mUserPaddingRight = mPaddingRight;
}
}