1 Star 0 Fork 0

coszero / CBRatingBar

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

CBRatingBar

等级评分控件,支持填充渐变,支持设置颜色、调整大小等,支持监听点击事件

本人已转前端开发,不再维护这个库了..

gif

gif gif gif

更新记录

所有版本更新信息

Gradle

  • add jitpack to your project's build.gradle:
    allprojects {
            repositories {
                ...
                maven { url 'https://jitpack.io' }
            }
        }
  • add the compile statement to your module's build.gradle:
    dependencies {
        compile 'com.github.CB-ysx:CBRatingBar:3.0.1'
    }

使用

  • xml
    <com.cb.ratingbar.CBRatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <com.cb.ratingbar.CBRatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:starSize="20dp"
        app:starCount="5"
        app:starSpace="10dp"
        app:starStrokeWidth="1dp"
        app:starCanTouch="true"
        app:starMaxProgress="120"
        app:starProgress="60"
        app:starShowStroke="true"
        app:starUseGradient="true"
        app:starStartColor="#0000ff"
        app:starEndColor="#00ff00"
        app:starCoverColor="#ff0000"
        app:starFillColor="#666666"
        app:starPointCount="5"
        app:starStrokeColor="#0f0f0f"
        app:starPathData="@string/bird"
        app:starPathDataId="@string/bird"
        app:starCoverDir="top_to_bottom"/>
  • java
cbRatingBar.setStarSize(20) //大小
        .setStarCount(5) //数量
        .setStarSpace(10) //间距
        .setShowStroke(true) //是否显示边框
        .setStarStrokeColor(Color.parseColor("#00ff00")) //边框颜色
        .setStarStrokeWidth(5) //边框大小
        .setStarFillColor(Color.parseColor("#00ff00")) //填充的背景颜色
        .setStarCoverColor(Color.parseColor("#ffffff")) //填充的进度颜色
        .setStarMaxProgress(120) //最大进度
        .setStarProgress(50) //当前显示的进度
        .setUseGradient(true) //是否使用渐变填充(如果使用则coverColor无效)
        .setStartColor(Color.parseColor("#000000")) //渐变的起点颜色
        .setEndColor(Color.parseColor("#ffffff")) //渐变的终点颜色
        .setCanTouch(true) //是否可以点击
        .setPathData(getResources().getString(R.string.pig)) //传入path的数据
        .setPathDataId(R.string.pig) //传入path数据id
        .setDefaultPath() //设置使用默认path
        .setPath(path) //传入path
        .setCoverDir(CBRatingBar.CoverDir.topToBottom) //设置进度覆盖的方向
        .setOnStarTouchListener(new CBRatingBar.OnStarTouchListener() { //点击监听
            @Override
            public void onStarTouch(int touchCount) {
                Toast.makeText(MainActivity.this, "点击第" + touchCount + "个星星", Toast.LENGTH_SHORT).show();
            }
        });

说明

pathData为svg文件中的path数据

感谢

解析svg数据转为path,用了RichPath中的两个类,感谢tarek360

License

Copyright 2017 CodeBear

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

空文件

简介

Git上的自定义评分控件,采用svg的方式编写,作者已不进行维护,拷贝下来看能力进行修改维护 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Android
1
https://gitee.com/xmqian/CBRatingBar.git
git@gitee.com:xmqian/CBRatingBar.git
xmqian
CBRatingBar
CBRatingBar
master

搜索帮助