趁着年轻,多学学

本人菜鸟一枚

画点point
package com.example.xfermodesdemo;

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

public class DrawPointActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {
		private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

		public SampleView(Context context) {
			super(context);
		}

		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = mPaint;
			canvas.translate(10, 10);
			canvas.drawColor(Color.WHITE);

			float[] pts = new float[] { 10, 20, 30, 40, 50, 60, 70, 80 };
			// (10,20),(30,40),(50,60),(70,80)

			paint.setColor(Color.RED);
			paint.setStrokeWidth(3);
			canvas.drawPoints(pts, paint);// 绘制四个点

			paint.setColor(Color.BLUE);
			paint.setStrokeWidth(0);
			canvas.drawLines(pts, paint);// 绘制两条线 line1 (10,20),(30,40);line2
											// (50,60),(70,80)
		}
	}
}

阅读更多
文章标签: Android point
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

画点point

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭