博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
省份封装代码
阅读量:4678 次
发布时间:2019-06-09

本文共 1521 字,大约阅读时间需要 5 分钟。

public class ProviceItem {

private Path path;

/**

* 绘制颜色
* */
private int drawColor;
public void setDrawColor(int drawColor){
this.drawColor = drawColor;
}

public ProviceItem(Path path) {

this.path = path;
}

public void drawItem(Canvas canvas, Paint paint,boolean isSelect){

if (isSelect){
//绘制内部颜色
paint.clearShadowLayer();
paint.setStrokeWidth(1);
paint.setStyle(Paint.Style.FILL);
paint.setColor(0xffff0000);
canvas.drawPath(path,paint);
//绘制边界
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0xFFD0E8F4);
canvas.drawPath(path,paint);
}else {
paint.setStrokeWidth(2);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);
paint.setShadowLayer(8,0,0,0xffffff);
canvas.drawPath(path,paint);
//绘制边界
paint.clearShadowLayer();
paint.setColor(drawColor);
paint.setStyle(Paint.Style.FILL);
paint.setStrokeWidth(2);
canvas.drawPath(path,paint);
}
}

public boolean isTouch(float x,float y){//注意注意这块是来判断点击位置的 主要知识点Region

RectF rectF = new RectF(http://www.amjmh.com/v/);
path.computeBounds(rectF,true);
Region region = new Region();
region.setPath(path,new Region((int)rectF.left,(int)rectF.top,(int)rectF.right,(int) rectF.bottom));
return region.contains((int)x,(int)y);
}
}
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
布局使用代码如下:

<com.goodboy.mile.View.ChinaMapView

android:layout_width="match_parent"
android:layout_height="match_parent" />
---------------------

转载于:https://www.cnblogs.com/hyhy904/p/11291159.html

你可能感兴趣的文章
CGRectGet *** 获取控件坐标的方法
查看>>
SQL的主键和外键约束
查看>>
Bookmarklet
查看>>
c++primer 第l六章编程练习答案
查看>>
上海秋季HCC小记
查看>>
Illustrator 上色
查看>>
truncate表恢复
查看>>
this关键字的使用
查看>>
Console.Read()、Console.ReadLine()、Console.ReadKey()
查看>>
ecere 编译过程中遇到的问题
查看>>
Cyclone V 与 Avalon-MM资料整理——DE1-SOC学习笔记(1)
查看>>
异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.
查看>>
Flask-SQLAlchemy
查看>>
C# - Generics
查看>>
.NET LINQ 转换数据类型
查看>>
[LGP2791] 幼儿园篮球题
查看>>
[linux-内核][转]内核日志及printk结构浅析
查看>>
SWMM[Storm Water Management Model]模型代码编译调试环境设置
查看>>
s11 day Linux 和nginx 部署
查看>>
程序猿的爱情-2012-01-22
查看>>