I have read many posts about my problem but I haven't found a solution. I'm going crazy!
I use the following code, in the main Class, to get the pulse on the screen:
public boolean onTouchEvent(MotionEvent event) {
x = (int) event.getX();
y = (int) event.getY();
case MotionEvent.ACTION_MOVE:
view.draw(canvas);
view.invalidate();
break;
}
view is:
DrawView view;
and DrawView is an inner class:
public class DrawView extends LinearLayout
and in the DrawView class I have the next two methods to draw the line:
public void draw(Canvas canvas) {
}
@Override
public void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
canvas.drawLine((int) 0,(int) 0,(int) x,(int) y, paint);
}
My problem is how to properly draw lines on screens with different screen densities. I've tried with:
float d = this.getResources().getDisplayMetrics().scaledDensity;
But I still can't paint the lines correctly.
Thanks for your attention!