Since few times the autocomplete box from Eclipse propose android:paddingStart android:paddingStop when I'm writing xml layout files.
I don't really understand what those attributes are supposed to do.
The eclipse/javadoc documentation is not really helpful :
Sets the padding, in pixels, of the start edge; see padding.
and the online documentation does not make any reference to those attributes : http://developer.android.com/reference/android/view/View.html
Could you explain me ?
After reading into the Android source code (View.java) it seems paddingStart and paddingEnd are helpful to take care of letter direction (left to right of right to left) defined by the user.
Thus, paddingStart is interpreted as paddingLeft in LTR (left-to-right) languages and paddingRight in RTL (right-to-left) languages.
Source code from 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;
}
}
Padding is used to add a blank space between a view and its contents.
android:paddingStart
Sets the padding at the start edge means at
the left side of viewandroid:paddingEnd
Sets the padding at the end edge means at the
right side of viewandroid:paddingBottom
Sets the padding at the bottom edgeandroid:paddingTop
Sets the padding at the top edgeIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With