Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

NotificationsYou must be signed in to change notification settings

charlieysx/CBRatingBar

Repository files navigation

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

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

gif

gifgifgif

更新记录

所有版本更新信息

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.CBRatingBarandroid:layout_width="wrap_content"android:layout_height="wrap_content"/>
    <com.cb.ratingbar.CBRatingBarandroid: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(newCBRatingBar.OnStarTouchListener() {//点击监听@OverridepublicvoidonStarTouch(inttouchCount) {Toast.makeText(MainActivity.this,"点击第" +touchCount +"个星星",Toast.LENGTH_SHORT).show();            }        });

说明

pathData为svg文件中的path数据

感谢

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

License

Copyright 2017 CodeBearLicensed 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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp