Answer the question
In order to leave comments, you need to log in
How to draw a rotating line segment on Android?
It is necessary to make a simple application for Android in Java
Essence: It is necessary to draw a segment that will rotate around one of its end points (essentially a clock hand)
I have not come across Android development before, I would like some links where you can read how to draw a line and do what -would it rotate, ready when naturally I don’t wait)
Answer the question
In order to leave comments, you need to log in
You write your control inheriting from the View
class.
You override its onDraw method in which you draw everything.
public class TimerView extends View {
@Override
public void onDraw(Canvas canvas) {
// Code
}
}
float angle = <angle> * Math.PI / 180;
float cos = (float)Math.cos(angle);
float sin = (float)Math.sin(angle);
canvas.drawLine(center.x + startradius * cos,
center.y + startradius * sin,
center.x + endradius * cos,
center.y + endradius * sin,
paint);
// Где <angle> в радианах
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question