在 Java 中的 Android 模拟器上在两点之间绘图
Drawing Between Two Points on an Android Emulator in Java
给定模拟器上的两个点(两个坐标的 x 和 y 值),如何画一条连接它们的线?
我已经检索到这样的两个坐标...
//imports not included
ViewGroup.MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(iv.getLayoutParams());
float fx = event.getX();
float fy = event.getY();
int x = (int)fx;
int y = (int)fy;
使用Canvas.drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
使用 X、Y 坐标在两点之间绘制直线的方法,如下面的代码片段。
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setStrokeWidth(5);
paint.setColor(Color.Black);
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
Canvas.drawLine(startX, startY, stopX, stopY, paint);
给定模拟器上的两个点(两个坐标的 x 和 y 值),如何画一条连接它们的线?
我已经检索到这样的两个坐标...
//imports not included
ViewGroup.MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(iv.getLayoutParams());
float fx = event.getX();
float fy = event.getY();
int x = (int)fx;
int y = (int)fy;
使用Canvas.drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
使用 X、Y 坐标在两点之间绘制直线的方法,如下面的代码片段。
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setStrokeWidth(5);
paint.setColor(Color.Black);
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
Canvas.drawLine(startX, startY, stopX, stopY, paint);