public class MarkerShowCmpt extends LinearLayout{
public MarkerShowCmpt(Context context, AttributeSet attrs) {
super(context, attrs);
}
private Paint paint;
public MarkerShowCmpt(Context context,String value) {
super(context);
}
/**
* #aedefe
* @param vauleColor
*/
public void setColor(String vauleColor){
init(vauleColor);
}
private void init(String vauleColor){
// 创建Paint
paint = new Paint();
// 设置抗锯齿效果
paint.setAntiAlias(true);
// 设置画刷的颜色
int color=Color.parseColor(vauleColor);
paint.setColor(color);
invalidate();
}
@Override
protected void onDraw(Canvas canvas){
int height=getHeight();
int width=getWidth();
paint.setStyle(Paint.Style.FILL);
canvas.drawRect(new RectF(0, 0,width,height-20), paint);
Path path =new Path();
path.moveTo(width/2-10,height-20);
path.lineTo(width/2+10,height-20);
path.lineTo(width/2,height);
canvas.drawPath(path, paint);
}
}
Android 画出三角形,正方型的坐标系!实现原理
最新推荐文章于 2021-05-28 08:06:41 发布