@@ -122,9 +122,9 @@ void loadFromAttributes(@NonNull TypedArray attributes) {
122122 attributes .getBoolean (R .styleable .MaterialButton_toggleCheckedStateOnClick , true );
123123
124124 // Store padding before setting background, since background overwrites padding values
125- int paddingStart = ViewCompat . getPaddingStart ( materialButton );
125+ int paddingLeft = materialButton . getPaddingLeft ( );
126126 int paddingTop = materialButton .getPaddingTop ();
127- int paddingEnd = ViewCompat . getPaddingEnd ( materialButton );
127+ int paddingRight = materialButton . getPaddingRight ( );
128128 int paddingBottom = materialButton .getPaddingBottom ();
129129
130130 // Update materialButton's background without triggering setBackgroundOverwritten()
@@ -134,11 +134,10 @@ void loadFromAttributes(@NonNull TypedArray attributes) {
134134 updateBackground ();
135135 }
136136 // Set the stored padding values
137- ViewCompat .setPaddingRelative (
138- materialButton ,
139- paddingStart + insetLeft ,
137+ materialButton .setPadding (
138+ paddingLeft + insetLeft ,
140139 paddingTop + insetTop ,
141- paddingEnd + insetRight ,
140+ paddingRight + insetRight ,
142141 paddingBottom + insetBottom );
143142 }
144143
@@ -384,14 +383,13 @@ private void updateButtonShape(@NonNull ShapeAppearanceModel shapeAppearanceMode
384383 // changing an existing drawable shape. This is a fallback.
385384 if (IS_LOLLIPOP && !backgroundOverwritten ) {
386385 // Store padding before setting background, since background overwrites padding values
387- int paddingStart = ViewCompat . getPaddingStart ( materialButton );
386+ int paddingLeft = materialButton . getPaddingLeft ( );
388387 int paddingTop = materialButton .getPaddingTop ();
389- int paddingEnd = ViewCompat . getPaddingEnd ( materialButton );
388+ int paddingRight = materialButton . getPaddingRight ( );
390389 int paddingBottom = materialButton .getPaddingBottom ();
391390 updateBackground ();
392391 // Set the stored padding values
393- ViewCompat .setPaddingRelative (
394- materialButton , paddingStart , paddingTop , paddingEnd , paddingBottom );
392+ materialButton .setPadding (paddingLeft , paddingTop , paddingRight , paddingBottom );
395393 } else {
396394 if (getMaterialShapeDrawable () != null ) {
397395 getMaterialShapeDrawable ().setShapeAppearanceModel (shapeAppearanceModel );
@@ -443,9 +441,9 @@ public void setInsetTop(@Dimension int newInsetTop) {
443441
444442 private void setVerticalInsets (@ Dimension int newInsetTop , @ Dimension int newInsetBottom ) {
445443 // Store padding before setting background, since background overwrites padding values
446- int paddingStart = ViewCompat . getPaddingStart ( materialButton );
444+ int paddingLeft = materialButton . getPaddingLeft ( );
447445 int paddingTop = materialButton .getPaddingTop ();
448- int paddingEnd = ViewCompat . getPaddingEnd ( materialButton );
446+ int paddingRight = materialButton . getPaddingRight ( );
449447 int paddingBottom = materialButton .getPaddingBottom ();
450448 int oldInsetTop = insetTop ;
451449 int oldInsetBottom = insetBottom ;
@@ -455,11 +453,10 @@ private void setVerticalInsets(@Dimension int newInsetTop, @Dimension int newIns
455453 updateBackground ();
456454 }
457455 // Set the stored padding values
458- ViewCompat .setPaddingRelative (
459- materialButton ,
460- paddingStart ,
456+ materialButton .setPadding (
457+ paddingLeft ,
461458 paddingTop + newInsetTop - oldInsetTop ,
462- paddingEnd ,
459+ paddingRight ,
463460 paddingBottom + newInsetBottom - oldInsetBottom );
464461 }
465462
0 commit comments