@@ -3093,13 +3093,13 @@ public void onClick(View v) {
30933093 setBackgroundDrawable(background);
30943094 }
30953095
3096- mUserPaddingRelative = (startPadding >= 0 || endPadding >= 0);
3097-
30983096 // Cache user padding as we cannot fully resolve padding here (we dont have yet the resolved
30993097 // layout direction). Those cached values will be used later during padding resolution.
31003098 mUserPaddingStart = startPadding;
31013099 mUserPaddingEnd = endPadding;
31023100
3101+ updateUserPaddingRelative();
3102+
31033103 if (padding >= 0) {
31043104 leftPadding = padding;
31053105 topPadding = padding;
@@ -3146,6 +3146,10 @@ public void onClick(View v) {
31463146 computeOpaqueFlags();
31473147 }
31483148
3149+ private void updateUserPaddingRelative() {
3150+ mUserPaddingRelative = (mUserPaddingStart >= 0 || mUserPaddingEnd >= 0);
3151+ }
3152+
31493153 /**
31503154 * Non-public constructor for use in testing
31513155 */
@@ -9599,6 +9603,8 @@ private void resolveLayoutDirectionIfNeeded() {
95999603 // Set to resolved
96009604 mPrivateFlags2 |= LAYOUT_DIRECTION_RESOLVED;
96019605 onResolvedLayoutDirectionChanged();
9606+ // Resolve padding
9607+ resolvePadding();
96029608 }
96039609
96049610 /**
@@ -9653,7 +9659,11 @@ public void resolvePadding() {
96539659
96549660 mUserPaddingBottom = (mUserPaddingBottom >= 0) ? mUserPaddingBottom : mPaddingBottom;
96559661
9656- recomputePadding();
9662+ if(isPaddingRelative()) {
9663+ setPaddingRelative(mUserPaddingStart, mPaddingTop, mUserPaddingEnd, mUserPaddingBottom);
9664+ } else {
9665+ recomputePadding();
9666+ }
96579667 onPaddingChanged(resolvedLayoutDirection);
96589668 }
96599669
@@ -12220,15 +12230,20 @@ public Drawable getBackground() {
1222012230 * @param bottom the bottom padding in pixels
1222112231 */
1222212232 public void setPadding(int left, int top, int right, int bottom) {
12223- boolean changed = false ;
12224-
12233+ mUserPaddingStart = -1 ;
12234+ mUserPaddingEnd = -1;
1222512235 mUserPaddingRelative = false;
1222612236
12237+ internalSetPadding(left, top, right, bottom);
12238+ }
12239+
12240+ private void internalSetPadding(int left, int top, int right, int bottom) {
1222712241 mUserPaddingLeft = left;
1222812242 mUserPaddingRight = right;
1222912243 mUserPaddingBottom = bottom;
1223012244
1223112245 final int viewFlags = mViewFlags;
12246+ boolean changed = false;
1223212247
1223312248 // Common case is there are no scroll bars.
1223412249 if ((viewFlags & (SCROLLBARS_VERTICAL|SCROLLBARS_HORIZONTAL)) != 0) {
@@ -12297,18 +12312,17 @@ public void setPadding(int left, int top, int right, int bottom) {
1229712312 * @param bottom the bottom padding in pixels
1229812313 */
1229912314 public void setPaddingRelative(int start, int top, int end, int bottom) {
12300- mUserPaddingRelative = true;
12301-
1230212315 mUserPaddingStart = start;
1230312316 mUserPaddingEnd = end;
12317+ mUserPaddingRelative = true;
1230412318
1230512319 switch(getResolvedLayoutDirection()) {
1230612320 case LAYOUT_DIRECTION_RTL:
12307- setPadding (end, top, start, bottom);
12321+ internalSetPadding (end, top, start, bottom);
1230812322 break;
1230912323 case LAYOUT_DIRECTION_LTR:
1231012324 default:
12311- setPadding (start, top, end, bottom);
12325+ internalSetPadding (start, top, end, bottom);
1231212326 }
1231312327 }
1231412328
0 commit comments