@@ -223,7 +223,7 @@ private void setBorderAttrs() {
223223 animateDrawablesEnterDuration , animateTextsEnterDuration , animateSelector , animateSelectorDuration , animateSelectorDelay , animateDrawablesExit ,
224224 animateDrawablesExitDuration , animateTextsExit , animateTextsExitDuration , lastPosition , buttonPadding ,
225225 buttonPaddingLeft , buttonPaddingRight , buttonPaddingTop , buttonPaddingBottom , groupBackgroundColor ,
226- dividerPadding , dividerSize , dividerRadius , bottomLineSize , bottomLineRadius , selectorSize , selectorRadius , initialPosition ,
226+ dividerPadding , dividerSize , dividerRadius , bottomLineSize , bottomLineRadius , selectorSize , selectorWidth , selectorRadius , initialPosition ,
227227 selectorDividerSize , selectorDividerRadius , selectorDividerColor , selectorDividerPadding , checkedButtonId ,
228228 animateTextsColorExit , animateTextsColorEnter , animateTextsColorDuration , animateTextsColorDurationExit , animateTextsColorDurationEnter ,
229229 animateDrawablesTintExit , animateDrawablesTintEnter , animateDrawablesTintDuration , animateDrawablesTintDurationExit , animateDrawablesTintDurationEnter ;
@@ -233,7 +233,7 @@ private void setBorderAttrs() {
233233 private boolean bottomLineBringToFront , selectorBringToFront , selectorAboveOfBottomLine , selectorTop , selectorBottom , hasPadding ,
234234 hasPaddingLeft , hasPaddingRight , hasPaddingTop , hasPaddingBottom , clickable , enabled ,
235235 enableDeselection , hasEnabled , hasClickable , hasBorder , hasAnimateDrawables , hasAnimateTexts , hasAnimation , selectorFullSize ,
236- hasAnimateTextsColor , hasAnimateDrawablesTint ;
236+ hasAnimateTextsColor , hasAnimateDrawablesTint , hasSelectorWidth ;
237237
238238 private void getAttributes (AttributeSet attrs ) {
239239 TypedArray ta = getContext ().obtainStyledAttributes (attrs , R .styleable .RadioRealButtonGroup );
@@ -262,6 +262,8 @@ private void getAttributes(AttributeSet attrs) {
262262 selectorBringToFront = ta .getBoolean (R .styleable .RadioRealButtonGroup_rrbg_selectorBringToFront , false );
263263 selectorAboveOfBottomLine = ta .getBoolean (R .styleable .RadioRealButtonGroup_rrbg_selectorAboveOfBottomLine , false );
264264 selectorSize = ta .getDimensionPixelSize (R .styleable .RadioRealButtonGroup_rrbg_selectorSize , 12 );
265+ selectorWidth = ta .getDimensionPixelSize (R .styleable .RadioRealButtonGroup_rrbg_selectorWidth , 0 );
266+ hasSelectorWidth = ta .hasValue (R .styleable .RadioRealButtonGroup_rrbg_selectorSize );
265267 selectorRadius = ta .getDimensionPixelSize (R .styleable .RadioRealButtonGroup_rrbg_selectorRadius , 0 );
266268
267269 animateSelector = ta .getInt (R .styleable .RadioRealButtonGroup_rrbg_animateSelector , 0 );
@@ -414,7 +416,18 @@ private void createSelectorItem(int position, RadioRealButton button) {
414416 int height = selectorSize ;
415417 if (selectorFullSize )
416418 height = LayoutParams .MATCH_PARENT ;
417- view .setLayoutParams (new LinearLayout .LayoutParams (0 , height , 1 ));
419+
420+ if (hasSelectorWidth ) {
421+ view .setLayoutParams (new LinearLayout .LayoutParams (selectorWidth , height ));
422+ } else {
423+ view .setLayoutParams (new LinearLayout .LayoutParams (LayoutParams .MATCH_PARENT , height ));
424+ }
425+
426+ LinearLayout wrapperView = new LinearLayout (getContext ());
427+ wrapperView .setLayoutParams (new LinearLayout .LayoutParams (0 , height , 1 ));
428+ wrapperView .setOrientation (LinearLayout .HORIZONTAL );
429+ wrapperView .setGravity (Gravity .CENTER );
430+ wrapperView .addView (view );
418431
419432 int value = 0 ;
420433 if (position == lastPosition ) {
@@ -423,27 +436,27 @@ private void createSelectorItem(int position, RadioRealButton button) {
423436
424437 switch (animationType ) {
425438 case ANIM_SCALE_X :
426- view .setScaleX (value );
439+ wrapperView .setScaleX (value );
427440 break ;
428441 case ANIM_SCALE_Y :
429- view .setScaleY (value );
442+ wrapperView .setScaleY (value );
430443 break ;
431444 case ANIM_TRANSLATE_X :
432445 if (value == 0 )
433- view .setVisibility (INVISIBLE );
446+ wrapperView .setVisibility (INVISIBLE );
434447 break ;
435448 case ANIM_TRANSLATE_Y :
436- view .setTranslationY (value == 1 ? value : selectorSize );
449+ wrapperView .setTranslationY (value == 1 ? value : selectorSize );
437450 break ;
438451 case ANIM_ALPHA :
439- view .setAlpha (value );
452+ wrapperView .setAlpha (value );
440453 break ;
441454 }
442455 button .setOnSelectorColorChangedListener (this , position );
443- updateViewSelectorColor (view , button .hasSelectorColor () ? button .getSelectorColor () : selectorColor );
456+ updateViewSelectorColor (wrapperView , button .hasSelectorColor () ? button .getSelectorColor () : selectorColor );
444457
445- v_selectors .add (view );
446- selectorContainer .addView (view );
458+ v_selectors .add (wrapperView );
459+ selectorContainer .addView (wrapperView );
447460 }
448461
449462 private void initButtonListener (RadioRealButton button , final int position ) {
@@ -1051,7 +1064,7 @@ public void onSelectorColorChanged(int position, int selectorColor) {
10511064
10521065 private void updateViewSelector (View view , int color , int radius , int size ) {
10531066 RoundHelper .makeRound (
1054- view ,
1067+ (( LinearLayout ) view ). getChildAt ( 0 ) ,
10551068 color ,
10561069 radius ,
10571070 selectorFullSize ? null : size
0 commit comments