我是靠谱客的博主 可靠香烟,这篇文章主要介绍android精确取点组件(实用地图上取点瞄准),现在分享给大家,希望可以做个参考。

复制代码
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.huangxudong.widget; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.view.View; public class PaintCycle extends View { private int cWidth; private int cHeight; private Path path = new Path(); private Path pathLeft = new Path(); private Path pathRight = new Path(); private Path pathTop = new Path(); private Path pathBottom = new Path(); private Paint fillPaint = new Paint(); private Paint sidePaint = new Paint(); private Paint pointPaint = new Paint(); public static PaintCycle INSTANCE; int[] centerPX = new int[2]; private int offsetX; private int offsetY; private int moveX; private int moveY; public PaintCycle(Context context) { super(context); INSTANCE = this; this.cWidth = (910 / 2); this.cHeight = (603 / 2); this.sidePaint.setColor(Color.argb(255, 0, 0, 0)); this.sidePaint.setStyle(Paint.Style.STROKE); this.sidePaint.setStrokeWidth(1.0F); this.sidePaint.setAntiAlias(true); this.fillPaint.setColor(Color.argb(32, 0, 0, 0)); this.fillPaint.setStyle(Paint.Style.FILL); this.fillPaint.setAntiAlias(true); this.pointPaint.setColor(Color.argb(255, 237, 28, 36)); this.pointPaint.setStyle(Paint.Style.FILL); this.pointPaint.setStrokeWidth(1.0F); this.pointPaint.setAntiAlias(true); move(0, 0); } public static PaintCycle getInstance() { return INSTANCE; } public int[] getCenterPX() { return this.centerPX; } protected void onDraw(Canvas canvas) { canvas.drawPath(this.path, this.sidePaint); canvas.drawPath(this.pathLeft, this.sidePaint); canvas.drawPath(this.pathRight, this.sidePaint); canvas.drawPath(this.pathTop, this.sidePaint); canvas.drawPath(this.pathBottom, this.sidePaint); canvas.drawPath(this.path, this.fillPaint); this.centerPX[0] = (this.cWidth + this.moveX + this.offsetX); this.centerPX[1] = (this.cHeight + this.moveY + this.offsetY); canvas.drawCircle(this.centerPX[0], this.centerPX[1], 1.5F, this.pointPaint); } public void move(int moveX, int moveY) { this.moveX = moveX; this.moveY = moveY; this.path.reset(); this.path.moveTo(this.cWidth - 50 + moveX + this.offsetX, this.cHeight - 50 + moveY + this.offsetY); this.path.lineTo(this.cWidth + 50 + moveX + this.offsetX, this.cHeight - 50 + moveY + this.offsetY); this.path.lineTo(this.cWidth + 50 + moveX + this.offsetX, this.cHeight + 50 + moveY + this.offsetY); this.path.lineTo(this.cWidth - 50 + moveX + this.offsetX, this.cHeight + 50 + moveY + this.offsetY); this.path.close(); this.pathLeft.reset(); this.pathLeft.moveTo(this.cWidth - 70 + moveX + this.offsetX, this.cHeight + moveY + this.offsetY); this.pathLeft.lineTo(this.cWidth - 30 + moveX + this.offsetX, this.cHeight + moveY + this.offsetY); this.pathRight.reset(); this.pathRight.moveTo(this.cWidth + 70 + moveX + this.offsetX, this.cHeight + moveY + this.offsetY); this.pathRight.lineTo(this.cWidth + 30 + moveX + this.offsetX, this.cHeight + moveY + this.offsetY); this.pathTop.reset(); this.pathTop.moveTo(this.cWidth + moveX + this.offsetX, this.cHeight - 70 + moveY + this.offsetY); this.pathTop.lineTo(this.cWidth + moveX + this.offsetX, this.cHeight - 30 + moveY + this.offsetY); this.pathBottom.reset(); this.pathBottom.moveTo(this.cWidth + moveX + this.offsetX, this.cHeight + 70 + moveY + this.offsetY); this.pathBottom.lineTo(this.cWidth + moveX + this.offsetX, this.cHeight + 30 + moveY + this.offsetY); postInvalidate(); } public void moveFinish() { this.offsetX = (this.moveX + this.offsetX); this.offsetY = (this.moveY + this.offsetY); this.moveX = (this.moveY = 0); } }

 

最后

以上就是可靠香烟最近收集整理的关于android精确取点组件(实用地图上取点瞄准)的全部内容,更多相关android精确取点组件(实用地图上取点瞄准)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(94)

评论列表共有 0 条评论

立即
投稿
返回
顶部