android 网格格式,android绘图网格线
package com.example.helloworldnn;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.view.View;public class MyCanva
package com.example.helloworldnn;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
public class MyCanvas extends View{
Paint paint; //绘图
public MyCanvas(Context context) {
super(context);
// TODO Auto-generated constructor stub
paint = new Paint();
paint.setColor(Color.YELLOW);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeWidth(3);
}
/**
* 绘制网格线
*/
protected void onDraw(Canvas canvas){
canvas.drawColor(Color.BLUE);
//canvas.drawCircle(100, 100, 90, paint);
final int width = 480; //hdpi 480x800
final int height = 800;
final int edgeWidth = 10;
final int space = 30; //长宽间隔
int vertz = 0;
int hortz = 0;
for(int i=0;i<100;i++){
canvas.drawLine(0, vertz, width, vertz, paint);
canvas.drawLine(hortz, 0, hortz, height, paint);
vertz+=space;
hortz+=space;
}
}
}
更多推荐
所有评论(0)