MainActivity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
第一种方法:
GuaTwo
public class GuaTwo extends View {
private Path mPath;
private Paint mOutterPaint;
private Canvas mCanvas;
private Bitmap mBitmap;
private int mLastX;
private int mLastY;
private Bitmap mOutterBitmap;
public GuaTwo(Context context) {
this(context, null);
}
public GuaTwo(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public GuaTwo(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getMeasuredWidth();
int height = getMeasuredHeight();
mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap);
setupOutPaint();
mCanvas.drawColor(Color.parseColor(