Exemplo n.º 1
0
  /** 构造函数,主要对一些对象初始化 */
  public MySurfaceView(Context context) {
    super(context);

    mHolder = this.getHolder(); // 获得SurfaceHolder对象
    mHolder.addCallback(this); // 添加状态监听

    mPaint = new Paint(); // 创建一个画笔对象
    mPaint.setColor(Color.WHITE); // 设置画笔的颜色为白色

    qPaint = new Paint(); // 创建一个画笔对象
    qPaint.setAntiAlias(true); // 消除锯齿
    qPaint.setStyle(Paint.Style.STROKE); // 设置画笔风格为描边
    qPaint.setStrokeWidth(3); // 设置描边的宽度为3
    qPaint.setColor(Color.GREEN); // 设置画笔的颜色为绿色

    // 创建路径对象
    mPath = new Path();
    qPath = new Path();
    tPath = new Path();

    // 设置坐标为50,100
    mX = 50;
    mY = 100;

    // 设置贝塞尔曲线的开始坐标为(10,200)
    qStartX = 10;
    qStartY = 200;

    setFocusable(true); // 设置焦点
  }
Exemplo n.º 2
0
 public MyView(Context context) {
   super(context);
   paint = new Paint();
   paint.setColor(Color.BLUE);
   paint.setStyle(Paint.Style.STROKE); // 设置画笔风格为描边
   paint.setStrokeWidth(10);
   random = new Random();
   setFocusable(true);
   holder = getHolder();
   holder.addCallback(this);
   path = new Path();
 }
Exemplo n.º 3
0
  public FlxGameView(FlxGame game, Context context, AttributeSet attrs) {
    super(context, attrs);

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);

    this.activity = (Activity) context;

    this.game = game;

    this.setFocusable(true);
    this.setFocusableInTouchMode(true);
  }
Exemplo n.º 4
0
 public GLView(Activity context) {
   super(context);
   act = context;
   glView = this;
   initSurface = false;
   initNative = false;
   SurfaceHolder holder = getHolder();
   holder.setType(SurfaceHolder.SURFACE_TYPE_GPU); // needed for Android 1.6
   holder.addCallback(this);
   mEglHelper = new EglHelper();
   mEglHelper.start();
   if (mEglHelper.configHasAlpha) holder.setFormat(PixelFormat.TRANSLUCENT);
   // Log.i(logTag, "set surface type");
   setFocusable(true);
   setFocusableInTouchMode(true);
   setKeepScreenOn(true);
 }
Exemplo n.º 5
0
 public ChartView(Context context, AttributeSet attrs, int defStyle) {
   super(context, attrs, defStyle);
   this.context = context;
   holder = getHolder();
   holder.addCallback(new ChartCallBack());
 }