package com.example.calsses;
import com.example.shu_ku.R;
import com.example.shu_ku.R.color;
import com.example.shu_ku.R.dimen;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.CornerPathEffect;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PathEffect;
import android.util.AttributeSet;
import android.widget.TextView;
//这都是最最基础的,留以备忘
public class MyView extends TextView {
private Paint paint;
private int line_color;
private float line_height;
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.my_view);
line_color = a.getColor(R.styleable.my_view_line_color, color.textColor_hui);
line_height = a.getDimension(R.styleable.my_view_line_height, 1);
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(line_height);
PathEffect effect = new CornerPathEffect(10);
paint.setPathEffect(effect);
}
//ksdljkdlgmkdfl
@Override
protected void onDraw(Canvas canvas) {
// 绘制一个几何形状
super.onDraw(canvas);
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(line_height);
CornerPathEffect effect = new CornerPathEffect(10);
paint.setPathEffect(effect);
Path path = new Path();
path.moveTo(10, 15);
path.lineTo(5, 10);
path.lineTo(2, 4);
path.lineTo(3, 6);
path.lineTo(7, 8);
path.lineTo(10, 10);
path.lineTo(10, 2);
path.lineTo(getWidth() - 2, 2);
path.lineTo(getWidth() - 2, getHeight() - 2);
path.lineTo(10, getHeight() - 2);
path.close();
canvas.drawPath(path, paint);
}
import com.example.shu_ku.R;
import com.example.shu_ku.R.color;
import com.example.shu_ku.R.dimen;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.CornerPathEffect;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PathEffect;
import android.util.AttributeSet;
import android.widget.TextView;
//这都是最最基础的,留以备忘
public class MyView extends TextView {
private Paint paint;
private int line_color;
private float line_height;
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.my_view);
line_color = a.getColor(R.styleable.my_view_line_color, color.textColor_hui);
line_height = a.getDimension(R.styleable.my_view_line_height, 1);
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(line_height);
PathEffect effect = new CornerPathEffect(10);
paint.setPathEffect(effect);
}
//ksdljkdlgmkdfl
@Override
protected void onDraw(Canvas canvas) {
// 绘制一个几何形状
super.onDraw(canvas);
paint.setAntiAlias(true);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(line_height);
CornerPathEffect effect = new CornerPathEffect(10);
paint.setPathEffect(effect);
Path path = new Path();
path.moveTo(10, 15);
path.lineTo(5, 10);
path.lineTo(2, 4);
path.lineTo(3, 6);
path.lineTo(7, 8);
path.lineTo(10, 10);
path.lineTo(10, 2);
path.lineTo(getWidth() - 2, 2);
path.lineTo(getWidth() - 2, getHeight() - 2);
path.lineTo(10, getHeight() - 2);
path.close();
canvas.drawPath(path, paint);
}
}
//涉及到的xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="my_view">
<attr name="line_color" format="color" />
<attr name="line_height" format="dimension" />
</declare-styleable>
</resources>