Android仿天眼查人物关系图

news/2024/7/8 10:35:53 标签: android

效果图预览

绘制思路

这里使用了中学解析几何知识 XPoint = OPointX = OPointXcosθ; YPoint = OPointY = OPointYsinθ;

canvas.drawText(lists.get(i).getName(), XPoint + (float) Math.cos(pere * i + 5) * radius[i % radius.length] - 30, YPoint + (float) Math.sin(pere * i + 5) * radius[i % radius.length] + 35, paint);

用法

1、XML布局(PS要根据自己的包名) <com.gkzy.relation.CirclePeopleView
   android:id="@+id/layout_cricle_people"
   android:layout_width="match_parent"
   android:layout_height="280dp"
   app:layout_constraintBottom_toBottomOf="parent"
   app:layout_constraintLeft_toLeftOf="parent"
   app:layout_constraintRight_toRightOf="parent"
   app:layout_constraintTop_toTopOf="parent" />
  
       
2.  peopleView = findViewById(R.id.layout_cricle_people);

3. 添加数据,刷新UI peopleView.SetFieldInfo(lists);
   peopleView.invalidate();
   
   
4.添加了view的点击事件,通过手势判断。原理:
每个圆的Cx,Cy,r都能获取到,然后通过已知数据计算RectF的
 left,  top,  right,  bottom
  /**
    * Create a new rectangle with the specified coordinates. Note: no range
    * checking is performed, so the caller must ensure that left <= right and
    * top <= bottom.
    *
    * @param left   The X coordinate of the left side of the rectangle
    * @param top    The Y coordinate of the top of the rectangle
    * @param right  The X coordinate of the right side of the rectangle
    * @param bottom The Y coordinate of the bottom of the rectangle
    */
   public RectF(float left, float top, float right, float bottom) {
       this.left = left;
       this.top = top;
       this.right = right;
       this.bottom = bottom;
   }
   
   得到RectF后判断contains(x,y)来获得点击的位置

项目源码:GitHub - chenhua1008611/Co-People: 仿天眼查关系图的生成,自定义view,随机颜色,随机大小


http://www.niftyadmin.cn/n/5537063.html

相关文章

HttpServer内存马

HttpServer内存马 基础知识 一些基础的方法和类 HttpServer&#xff1a;HttpServer主要是通过带参的create方法来创建&#xff0c;第一个参数InetSocketAddress表示绑定的ip地址和端口号。第二个参数为int类型&#xff0c;表示允许排队的最大TCP连接数&#xff0c;如果该值小…

软件测试面试题:怎么优化SQL的查询速度?

索引优化&#xff1a;确保查询中用到的字段上有合适的索引。索引可以显著加快数据检索速度&#xff0c;但也要注意不要过度索引&#xff0c;因为索引虽然可以加快查询速度&#xff0c;但会降低更新表的速度。 查询语句优化&#xff1a;避免使用SELECT *&#xff0c;尽量指定需…

【C语言】通过fgets和fscanf了解读写文件流的概念

在C语言中&#xff0c;fgets和fscanf都是用于从文件或输入流中读取数据的函数&#xff0c;但它们的工作方式和用途有所不同。 1.fgets&#xff08;Get File String&#xff09; 示例代码&#xff1a; char buffer[100]; fgets(buffer, sizeof(buffer), stdin); fgets 函数用于…

ubuntu 18 虚拟机安装(5) postgres sql 数据库 简单 应用

ubuntu 18 虚拟机安装&#xff08;5&#xff09; postgres sql 数据库 简单 应用 参考 PostgreSQL的基本使用整理 https://blog.csdn.net/qq_45658339/article/details/124431612 sudo su - postgres psqlsudo -u postgres psqlsudo systemctl status postgresql sudo syste…

k8s 常用的命令

k8s 常用的操作 查找资源 kubectl get&#xff1a; 获取所有的资源&#xff0c;包括node、namespace、pod 、service、deployment等&#xff0c;可以展示一个或者多个资源。 创建资源 kubectl create &#xff1a;Kubernetes 的清单文件可以用 json 或 yaml 定义。 更新资源 …

去中心化技术对云计算的潜在影响与应用

随着去中心化技术如区块链的发展&#xff0c;云计算领域也面临着新的变革与挑战。本文将深入探讨去中心化技术对云计算的潜在影响及其应用前景&#xff0c;从技术基础到实际案例&#xff0c;逐步揭示这一新兴领域的发展趋势与可能带来的革新。 1. 介绍&#xff1a;云计算的现状…

PHP景区旅游多商户版微信小程序系统源码

解锁景区新玩法&#xff01;​ 引言&#xff1a;一站式旅行新体验 厌倦了传统景区的单调游览&#xff1f;想要一次旅行就能体验多种风情&#xff1f;那么&#xff0c;“景区旅游多商户版”绝对是你的不二之选&#xff01;这个创新模式将景区内多个商户资源整合&#xff0c;为…

爬虫-豆瓣电影排行榜

获取数据 requests库 获取数据环节需要用到requests库。安装方式也简单 pip install requests 爬取页面豆瓣读书 Top 250 用requests库来访问 import requests res requests.get(https://book.douban.com/top250/) 解析&#xff1a; 导入requests库调用了requests库中的…