zoukankan      html  css  js  c++  java
  • Android随笔

    学习绘图软件

    * Created by Jay on 2015/10/15 0015. */ public class MyView extends View{ private Paint mPaint; public MyView(Context context) { super(context); init(); } public MyView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public MyView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init(){ mPaint = new Paint(); mPaint.setAntiAlias(true); //抗锯齿 mPaint.setColor(getResources().getColor(R.color.puple));//画笔颜色 mPaint.setStyle(Paint.Style.FILL); //画笔风格 mPaint.setTextSize(36); //绘制文字大小,单位px mPaint.setStrokeWidth(5); //画笔粗细 } //重写该方法,在这里绘图 @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); } }

    然后布局那里设置下这个View就好,下述代码都写在onDrawable中~


    1)设置画布颜色:

    canvas.drawColor(getResources().getColor(R.color.yellow));   //设置画布背景颜色

    2)绘制圆形:

    canvas.drawCircle(200, 200, 100, mPaint);           //画实心圆

  • 相关阅读:
    GO语言网络编程
    GO语言测试
    GO语言反射
    GO语言strconv包的使用
    GO语言并发
    Centos7 开启swap分区
    设计模式 之 命令模式
    设计模式 之 代理模式
    设计模式 之 工厂模式
    设计模式 之 观察者模式
  • 原文地址:https://www.cnblogs.com/wrx166/p/14911340.html
Copyright © 2011-2022 走看看