@@ -132,6 +132,9 @@ public static class Builder {
132132
133133 private boolean hasSelectDrawable = false ;
134134
135+ private GradientDrawable baseGradientDrawable = null ;
136+ private StateListDrawable baseStateListDrawable = null ;
137+
135138 public Builder setShape (Shape shape ) {
136139 this .shape = shape ;
137140 return this ;
@@ -482,6 +485,17 @@ public Builder setUnFocusedTextColor(int unFocusedTextColor) {
482485 return this ;
483486 }
484487
488+ public Builder setBaseGradientDrawable (GradientDrawable baseGradientDrawable ) {
489+ this .baseGradientDrawable = baseGradientDrawable ;
490+ return this ;
491+ }
492+
493+ public Builder setBaseStateListDrawable (StateListDrawable baseStateListDrawable ) {
494+ this .baseStateListDrawable = baseStateListDrawable ;
495+ return this ;
496+ }
497+
498+
485499 public Drawable build () {
486500 GradientDrawable drawable = null ;
487501 StateListDrawable stateListDrawable = null ;
@@ -582,7 +596,7 @@ private ColorStateList getColorStateList() {
582596 }
583597
584598 private StateListDrawable getStateListDrawable () {
585- StateListDrawable stateListDrawable = null ;
599+ StateListDrawable stateListDrawable = baseStateListDrawable ;
586600 if (checkableDrawable != null ) {
587601 stateListDrawable = getStateListDrawable (stateListDrawable );
588602 stateListDrawable .addState (new int []{android .R .attr .state_checkable }, checkableDrawable );
@@ -652,7 +666,10 @@ private StateListDrawable getStateListDrawable() {
652666
653667 @ NonNull
654668 private GradientDrawable getGradientDrawable () {
655- GradientDrawable drawable = new GradientDrawable ();
669+ GradientDrawable drawable = baseGradientDrawable ;
670+ if (drawable == null ) {
671+ drawable = new GradientDrawable ();
672+ }
656673 drawable .setShape (shape .value );
657674
658675 if (cornersRadius != null ) {
@@ -735,7 +752,6 @@ private GradientDrawable getGradientDrawable() {
735752 drawable .setGradientType (gradient .value );
736753 drawable .setUseLevel (useLevel );
737754 if (!padding .isEmpty ()) {
738-
739755 if (android .os .Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
740756 drawable .setPadding (padding .left , padding .top , padding .right , padding .bottom );
741757 } else {
@@ -749,7 +765,6 @@ private GradientDrawable getGradientDrawable() {
749765 e .printStackTrace ();
750766 }
751767 }
752-
753768 }
754769 if (sizeWidth != null && sizeHeight != null ) {
755770 drawable .setSize (sizeWidth .intValue (), sizeHeight .intValue ());
0 commit comments