blob: 9a5b5c1f03147e5911986229b753caede501536f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package com.mapswithme.maps.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.ImageView;
public class ArrowView extends ImageView
{
private float mWidth;
private float mHeight;
private float mAngle;
public ArrowView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public void setAzimuth(double azimuth)
{
mAngle = (float) Math.toDegrees(azimuth);
invalidate();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
mWidth = getWidth();
mHeight = getHeight();
}
@Override
protected void onDraw(@NonNull Canvas canvas)
{
canvas.save();
canvas.rotate(mAngle, mWidth / 2, mHeight / 2);
super.onDraw(canvas);
canvas.restore();
}
}
|