0

我有一个程序来显示它基于手机传感器工作的指南针。现在我的问题是设置背景资源(针图像)而不是java绘制的线。

代码

  protected void onDraw(Canvas canvas) {
    int xPoint = getMeasuredWidth() / 2;
    int yPoint = getMeasuredHeight() / 2;

    float radius = (float) (Math.max(xPoint, yPoint) * 0.6);
    canvas.drawCircle(xPoint, yPoint, radius, paint);

    // 3.143 is a good approximation for the circle
    canvas.drawLine(xPoint, yPoint, (float) (xPoint + radius * Math.sin((double) (-position) / 180 * 3.143)),
        (float) (yPoint - radius * Math.cos((double) (-position) / 180 * 3.143))*2, paint);



  }

我想要一个真实的图像而不是这个 drawLine 并且应该保持我通过的位置。任何人请帮我解决这个问题。

4

0 回答 0