zoukankan      html  css  js  c++  java
  • 省份封装代码

    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" />
    ---------------------

  • 相关阅读:
    mysql存储过程的优点
    MySQL复制
    优化数据库的方法
    MySQL表分区
    Http请求
    memcache和redis的区别
    触发器实现原理
    PHP常见数组函数与实例
    git 打包指定提交过的代码
    发送HTTP请求方法
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11291159.html
Copyright © 2011-2022 走看看