zoukankan      html  css  js  c++  java
  • 15_Canvas画图形


    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Paint;
    import android.graphics.Paint.Style;
    import android.view.Menu;
    import android.view.View;
    import android.view.Window;
    import android.view.WindowManager;

    public class MainActivity extends Activity {
      
        
         @Override
         public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             requestWindowFeature(Window.FEATURE_NO_TITLE);
             getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
             setContentView(new RenderView(this));
         }
     }

    class RenderView extends View {       
        Paint paint;
       
        public RenderView(Context context) {
            super(context);
            paint = new Paint();           
        }
       
        protected void onDraw(Canvas canvas) {
         //背景
            canvas.drawRGB(255, 255, 255);      
            //划线
            paint.setColor(Color.RED);
            canvas.drawLine(0, 0, canvas.getWidth()-1, canvas.getHeight()-1, paint);
           
            //画园
            paint.setStyle(Style.STROKE);
            paint.setColor(0xff00ff00);           
            canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 40, paint);
                       
            //画矩形
            paint.setStyle(Style.FILL);
            paint.setColor(0x770000ff);
            canvas.drawRect(100, 100, 200, 200, paint);
            invalidate();
        }
    }

  • 相关阅读:
    [VC++]轻松搞VC之定时器(Timer)
    [VC++]VC中如何获得当前系统时间
    [VC++]如何利用this获得窗口句柄
    SMART原则
    SQL配置
    术语百科
    关于SQL锁问题
    第六代OA办公理念(摘录)
    心动机型
    SQL2008R2的索引重建
  • 原文地址:https://www.cnblogs.com/xl711436/p/3060783.html
Copyright © 2011-2022 走看看