1111public class RoundedShadowLayout extends ShadowLayout {
1212 private final RoundedShadowOutlineProvider mRoundedShadowOutlineProvider = new RoundedShadowOutlineProvider ();
1313
14+ private boolean mRoundedCornerRadiusAdaptation = true ;
15+
1416 public RoundedShadowLayout (Context context ) {
1517 this (context , null );
1618 }
@@ -25,6 +27,7 @@ public RoundedShadowLayout(Context context, AttributeSet attrs, int defStyleAttr
2527 setClipToShadowOutline (true );
2628 setClipToPadding (false );
2729 TypedArray typedArray = context .obtainStyledAttributes (attrs , R .styleable .RoundedShadowLayout );
30+ mRoundedCornerRadiusAdaptation = typedArray .getBoolean (R .styleable .RoundedShadowLayout_roundedCornerRadiusAdaptation , mRoundedCornerRadiusAdaptation );
2831 float cornerRadius = typedArray .getDimension (R .styleable .RoundedShadowLayout_roundedCornerRadius , 0F );
2932 float cornerRadiusTopLeft = typedArray .getDimension (R .styleable .RoundedShadowLayout_roundedCornerRadiusTopLeft , cornerRadius );
3033 float cornerRadiusTopRight = typedArray .getDimension (R .styleable .RoundedShadowLayout_roundedCornerRadiusTopRight , cornerRadius );
@@ -36,13 +39,19 @@ public RoundedShadowLayout(Context context, AttributeSet attrs, int defStyleAttr
3639
3740 @ Override
3841 protected int getSuggestedMinimumWidth () {
42+ if (mRoundedCornerRadiusAdaptation ) {
43+ return super .getSuggestedMinimumWidth ();
44+ }
3945 int radiusLeft = (int ) Math .max (getTopLeftCornerRadius (), getBottomLeftCornerRadius ());
4046 int radiusRight = (int ) Math .max (getTopRightCornerRadius (), getBottomRightCornerRadius ());
4147 return radiusLeft + radiusRight + super .getSuggestedMinimumWidth ();
4248 }
4349
4450 @ Override
4551 protected int getSuggestedMinimumHeight () {
52+ if (mRoundedCornerRadiusAdaptation ) {
53+ return super .getSuggestedMinimumHeight ();
54+ }
4655 int radiusTop = (int ) Math .max (getTopLeftCornerRadius (), getTopRightCornerRadius ());
4756 int radiusBottom = (int ) Math .max (getBottomLeftCornerRadius (), getBottomRightCornerRadius ());
4857 return radiusTop + radiusBottom + super .getSuggestedMinimumHeight ();
@@ -76,6 +85,17 @@ public boolean areCornersRadiusSame() {
7685 return mRoundedShadowOutlineProvider .areCornersRadiusSame ();
7786 }
7887
88+ public boolean isRoundedCornerRadiusAdaptation () {
89+ return mRoundedCornerRadiusAdaptation ;
90+ }
91+
92+ public void setRoundedCornerRadiusAdaptation (boolean roundedCornerRadiusAdaptation ) {
93+ if (mRoundedCornerRadiusAdaptation != roundedCornerRadiusAdaptation ) {
94+ mRoundedCornerRadiusAdaptation = roundedCornerRadiusAdaptation ;
95+ requestLayout ();
96+ }
97+ }
98+
7999 public void setCornerRadius (float cornerRadius ) {
80100 setCornerRadius (cornerRadius , cornerRadius , cornerRadius , cornerRadius );
81101 }
0 commit comments