該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓
這是X和Y軸的畫圖代碼
int height=getHeight();
int width=getWidth();
float originX=width/2,originY=height/2;
Toast.makeText(chart.this,"坐标系大小為:"+height+"x"+width,Toast.LENGTH_LONG).show();
//x軸
canvas.drawLine(0,height/2,width,height/2,paint);
Path trianglex=new Path();
trianglex.moveTo(width/2,0);trianglex.lineTo(width/2+10,20);trianglex.lineTo(width/2-10,20);trianglex.lineTo(width/2,0);trianglex.close();
canvas.drawPath(trianglex,paint);//箭頭三角形
canvas.drawPosText("X", new float[]{width/2-20,20}, paint);
//y軸
canvas.drawLine(width/2,0,width/2,height,paint);
Path triangley=new Path();
triangley.moveTo(width,height/2);triangley.lineTo(width-20,height/2+10);triangley.lineTo(width-20,height/2-10);triangley.lineTo(width,height/2);triangley.close();
canvas.drawPath(triangley,paint);//箭頭三角形
canvas.drawPosText("Y", new float[]{width-20,height/2+20}, paint);