1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| import android.content.Context; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.RectF; import android.util.AttributeSet; import android.widget.FrameLayout;
public class RoundRectViewGroup extends FrameLayout { private float radio = 0;
public RoundRectViewGroup(Context context) { super(context); }
public RoundRectViewGroup(Context context, AttributeSet attrs) { super(context, attrs); }
public RoundRectViewGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
@Override protected void dispatchDraw(Canvas canvas) { Path path = new Path(); radio=getWidth() / 3.5f; path.addRoundRect( new RectF(0, 0, getWidth(), getHeight()) , new float[]{radio, radio, radio, radio, radio, radio, radio, radio} , Path.Direction.CW); canvas.clipPath(path);
super.dispatchDraw(canvas); }
@Override public boolean shouldDelayChildPressedState() { return false; } }
|