自己写个椭圆摆上去
<com.as.zqfjavasample.base.custom_views.TuoyuanView
android:layout_width="@dimen/dp160"
android:layout_height="@dimen/dp60"
/>
宽高变化,也就变化了
public class TuoyuanView extends View {
private Paint mPaint;
public TuoyuanView(Context context) {
this(context, null);
}
public TuoyuanView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public TuoyuanView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaint = new Paint();
mPaint.setStyle(Paint.Style.FILL);
mPaint.setDither(true);
mPaint.setAntiAlias(true);
mPaint.setColor(Color.RED);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = getWidth();
int height = getHeight();
Path path = new Path();
path.moveTo(0, height);
path.quadTo(width/2, height / 2, width, height);
path.close();
canvas.drawPath(path, mPaint);
}
}