View 的绘制笔记一

自定义绘制的四个级别

  1. Canvas 的 drawXXX系列方法及Paint 最常见的使用
  2. Paint 的完全攻略
  3. Canvas 对绘制的辅助—范围剪裁和几何变换
  4. 使用不同的绘制方法控制绘制顺序

Canvas.drawXXX() 系列方法、Paint 基础

Canvas 类下的 drawXXX() 方法:

  1. drawColor()、drawRGB()、drawARGB() 绘制颜色
  2. drawCircle(float centerX, float centerY, float radius, Paint paint) 绘制圆形
  3. drawRect(float left, float top, float right, float bottom, Paint paint)、drawRect(RectF rectf, Paint paint)、drawRect(Rect rect, Paint paint) 绘制矩形
  4. drawPoint(float x, float y, Paint paint) 绘制点
  5. drawPoints(float[] pts, int offset, int count, Paint paint)、 drawPoints(float[] pts, Paint paint) 绘制一组点
  6. drawOval(float left, float top, float right, float bottom, Paint paint) 绘制椭圆
  7. drawLine(float startX, float startY, float stopX, float stopY, Paint paint) 绘制直线
  8. drawLines(float[] pts, int offset, int count, Paint paint)、drawLines(float[] pts, Paint paint) 绘制一组直线
  9. drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, Paint paint)、 drawRoundRect(Rectf rectf, float rx, float ry, Paint paint) 绘制圆角矩形
  10. drawArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean userCenter, Paint paint) 绘制扇形或弧形
  11. drawPath(Path path, Paint paint) 绘制自定义路径

Paint 基础

  1. Paint.setColor(int color)
  2. Paint.setStyle(Paint.Style style)
  3. Paint.setStokeWidth(float width)
  4. Paint.setAntiAlis(boolean b) 抗锯齿效果
  5. Paint.setTextSize(float textSize)

Path

  • 添加子图形—addXXX

    1. addCircle(float centerX, float centerY, float radius, Derection dir)
    2. addOval(float left, float top, float right, float bottom, Direction dir)
    3. 其他类似
    4. addPath(Path path) 添加一个path
  • 画线(直线或者曲线)— xxxTo()

    1. lineTo(float x, float y) / rLineTo(float x, float y) 画直线
    2. quadTo(float x1, float y1, float x2, float y2) / rQuadTo(float x1, float x2, float y1, float y2) 画贝塞尔曲线
    3. moveTo(float x, float y) / rMoveTo(float x, float y) 移动到目标位置
    4. arcTo(Rectf oval, float startAngle, float sweepAngle, boolean forceMoveTo) 画弧线

你可能感兴趣的:(Android,View,android,view,绘制)