What are paddingStart and paddingEnd?

后端 未结 2 918
失恋的感觉
失恋的感觉 2021-02-07 11:25

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 th

相关标签:
2条回答
  • 2021-02-07 11:57

    When working with and reading this I realize it is paddingStart and paddingEND and not paddingSTOP (although this element exists).

    0 讨论(0)
  • 2021-02-07 12:01

    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;
                }
        }
    
    0 讨论(0)
提交回复
热议问题