Android系列之手机多点触摸画圆

本文介绍了一个Android应用示例,通过创建`MyCircle`类表示圆,并在`MyView`类中处理多点触摸事件,动态绘制不同颜色的圆。当手指按下时,实例化一个圆并在屏幕上显示;手指移动时更新圆的位置;手指抬起时移除对应的圆。实现了多指同时在屏幕上画圆的功能。
摘要由CSDN通过智能技术生成

1、先写个实体类,代表圆

  1. public class MyCircle {  
  2.     public float x;  
  3.     public float y;  
  4.     public int r=100;  
  5.     public int pointId;  
  6.     int red;  
  7.     int green;  
  8.     int blue;  
  9.     Random random=new Random();  
  10.   
  11.     public MyCircle(float x, float y, int pointId) {  
  12.         this.x = x;  
  13.         this.y = y;  
  14.         this.pointId = pointId;  
  15.         red=random.nextInt(255);  
  16.         green=random.nextInt(255);  
  17.         blue=random.nextInt(255);  
  18.     }  
  19.     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值