{"id":13644191,"url":"https://github.com/panpf/spider-web-score-view","last_synced_at":"2025-04-05T05:09:13.663Z","repository":{"id":57734436,"uuid":"48904550","full_name":"panpf/spider-web-score-view","owner":"panpf","description":"SpiderWebScoreView 是 Android 上的一个蛛网评分控件 SpiderWebScoreView Android is used on a cobweb score view","archived":false,"fork":false,"pushed_at":"2021-05-25T06:49:51.000Z","size":196,"stargazers_count":640,"open_issues_count":0,"forks_count":104,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-08-04T00:06:50.133Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/panpf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-02T09:09:56.000Z","updated_at":"2024-08-02T07:42:34.000Z","dependencies_parsed_at":"2022-08-24T01:21:07.589Z","dependency_job_id":null,"html_url":"https://github.com/panpf/spider-web-score-view","commit_stats":null,"previous_names":["xiaopansky/spiderwebscoreview"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fspider-web-score-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fspider-web-score-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fspider-web-score-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panpf%2Fspider-web-score-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panpf","download_url":"https://codeload.github.com/panpf/spider-web-score-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289429,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:01:58.852Z","updated_at":"2025-04-05T05:09:13.626Z","avatar_url":"https://github.com/panpf.png","language":"Java","funding_links":[],"categories":["RatingView"],"sub_categories":[],"readme":"# ![logo_image] SpiderWebScoreView\n\n![Platform][platform_image]\n[![API][min_api_image]][min_api_link]\n[![Android Arsenal][android_arsenal_image]][android_arsenal-link]\n[![Release Version][version_icon]][version_link]\n\nSpiderWebScoreView 是一个蛛网评分控件，可以方便的显示任意层级任意维度的数据\n\n![sample_image]\n\n## 特点\n* 支持`任意个角`以及`任意层级`\n* 蛛网图形外边的分数文案支持`任意样式`\n* 不管是多少维度都可`左右对称`\n\n## 开始使用\n\n### 1. 从 mavenCentral 导入 SpiderWebScoreView\n\n在 app 的 build.gradle 文件的 dependencies 节点中加入依赖\n\n```kotlin\ndependencies{\n\timplementation(\"io.github.panpf.spiderwebscoreview:spiderwebscoreview:${LAST_VERSION}\")\n}\n```\n\n`${LAST_VERSION}`: [![Download][version_icon]][version_link] (No include 'v')\n\n最低支持 `Android2.3`\n\n### 2. 在布局中使用\n\n在布局中使用声明 SpiderWebScoreView 和 CircularLayout，如下：\n\n```xml\n\u003cFrameLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"150dp\"\n    android:clipChildren=\"false\"\u003e\n\n    \u003cme.panpf.swsv.SpiderWebScoreView\n        android:id=\"@+id/spiderWeb_mainActivity_1\"\n        android:layout_width=\"100dp\"\n        android:layout_height=\"100dp\"\n        android:layout_gravity=\"center\" /\u003e\n\n    \u003cme.panpf.swsv.CircularLayout\n        android:id=\"@+id/layout_mainActivity_circular1\"\n        android:layout_width=\"100dp\"\n        android:layout_height=\"100dp\"\n        android:layout_gravity=\"center\"\n        android:clipChildren=\"false\"/\u003e\n\u003c/FrameLayout\u003e\n\n```\n详解：\n* SpiderWebScoreView 用来显示蛛网图形\n* CircularLayout 用来显示四周的文案\n* CircularLayout 的 `尺寸` 必须和 SpiderWebScoreView `一致` 并且是层叠关系\n* CircularLayout 的子 View 将会显示在圆圈的外面，因此 `CircularLayout` 和其 `父 FrameLayout` 都必须设置 `clipChildren 为 false`\n* 父 FrameLayout 还要比 CircularLayout `大一圈`，大的这一圈就是用来显示 CircularLayout 的子 View，具体大多少视你的需求而定\n\n### 3. 在代码中设置分值\n\n在代码中通过 SpiderWebScoreView.setScores(float maxScore, float[] scores) 方法设置最大分数以及所有分值即可\n\n* 有多少个分值（scores.length）蛛网图形就有多少个角\n* 默认分 5 层\n\n然后根据你的需求往 CircularLayout 里面添加显示分数的 View 即可，数量和顺序必须同 scores 相同，如下：\n\n```java\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_main);\n\n    SpiderWebScoreView spiderWebScoreView1 = (SpiderWebScoreView) findViewById(R.id.spiderWeb_mainActivity_1);\n    CircularLayout circularLayout1 = (CircularLayout) findViewById(R.id.layout_mainActivity_circular1);\n\n\tScore[] scores = new Score[]{\n\t\tnew Score(7.0f, R.drawable.vip_icon7),\n\t\tnew Score(8.0f, R.drawable.vip_icon8),\n\t\tnew Score(5.0f, R.drawable.vip_icon5),\n\t\tnew Score(5.0f, R.drawable.vip_icon5),\n\t\tnew Score(8.0f, R.drawable.vip_icon8),\n\t\tnew Score(7.0f, R.drawable.vip_icon7),\n\t};\n    setup(spiderWebScoreView1, circularLayout1, scores);\n}\n\nprivate void setup(SpiderWebScoreView spiderWebScoreView, CircularLayout circularLayout, Score... scores){\n\tfloat[] scoreArray = new float[scores.length];\n    for(int w = 0; w \u003c scores.length; w++){\n        scoreArray[w] = scores[w].score;\n    }\n    spiderWebScoreView.setScores(10f, scoreArray);\n\n    circularLayout.removeAllViews();\n    for(Score score : scores){\n        TextView scoreTextView = (TextView) LayoutInflater.from(getBaseContext()).inflate(R.layout.score, circularLayout, false);\n        scoreTextView.setText(score.score+\"\");\n        if(score.iconId != 0){\n            scoreTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, score.iconId, 0);\n        }\n        circularLayout.addView(scoreTextView);\n    }\n}\n\nprivate static class Score{\n    private float score;\n    private int iconId;\n\n    private Score(float score, int iconId) {\n        this.score = score;\n        this.iconId = iconId;\n    }\n\n    private Score(float score) {\n        this.score = score;\n    }\n}\n```\n\n### 4. 布局属性\n\nSpiderWebScoreView\n\n|属性名|介绍|对应方法|缺省值|\n|:--|:--|:--|:--|\n|angleCount|设置蛛网图形有多少个角|会在setScores(float, float[])方法中根据scores的长度来覆盖此参数|5|\n|hierarchyCount|设置蛛网图形有多少层|setHierarchyCount(int)|5|\n|maxScore|最大分值|setScores(float, float[])方法的第一个参数就是maxScore|10f|\n|lineColor|蛛网线条的颜色|setLineColor(int)|0xFF000000|\n|lineWidth|蛛网线条的宽度|setLineWidth(float)|-1(不设置，Paint默认宽度)|\n|scoreColor|分数图形的颜色|setScoreColor(int)|0x80F65801|\n|scoreStrokeColor|分数图形描边的颜色|setScoreStrokeColor(int)|0xFFF65801|\n|scoreStrokeWidth|分数图形描边的宽度|setScoreStrokeWidth(float)|-1(不设置，Paint默认宽度)\n|disableScoreStroke|禁用分数图形描边|setDisableScoreStroke(boolean)|false|\n\nCircularLayout\n\n|属性名|介绍|对应方法|缺省值|\n|:--|:--|:--|:--|\n|spacing|设置子View与圆圈之间的距离|setSpacing(int)|8dp|\n\n更多示例请参考 sample 源码\n\n## License\n    Copyright (C) 2017 Peng fei Pan \u003csky@panpf.me\u003e\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n[logo_image]: https://github.com/panpf/spider-web-score-view/raw/master/docs/icon.png\n[platform_image]: https://img.shields.io/badge/Platform-Android-brightgreen.svg\n[min_api_image]: https://img.shields.io/badge/API-9%2B-orange.svg\n[min_api_link]: https://android-arsenal.com/api?level=9\n[android_arsenal_image]: https://img.shields.io/badge/Android%20Arsenal-SpiderWebScoreView-green.svg?style=true\n[android_arsenal-link]: https://android_arsenal.com/details/1/4167\n[version_icon]: https://img.shields.io/maven-central/v/io.github.panpf.spiderwebscoreview/spiderwebscoreview\n[version_link]: https://repo1.maven.org/maven2/io/github/panpf/spiderwebscoreview/\n[sample_image]: https://github.com/panpf/spider-web-score-view/raw/master/docs/sample.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanpf%2Fspider-web-score-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanpf%2Fspider-web-score-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanpf%2Fspider-web-score-view/lists"}