项目作者: Jamshid-M

项目描述 :
RatingBar with exact values
高级语言: Kotlin
项目地址: git://github.com/Jamshid-M/ExactRatingBar.git
创建时间: 2019-09-25T10:27:14Z
项目社区:https://github.com/Jamshid-M/ExactRatingBar

开源协议:

下载


ExactRatingBar

Android Arsenal

RatingBar with exact values.

Usage

Add it in your root build.gradle at the end of repositories

  1. repositories {
  2. maven { url 'https://jitpack.io' }
  3. }
  1. dependencies {
  2. implementation 'com.github.Jamshid-M:ExactRatingBar:1.0.0'
  3. }

Open activity and specify ExactRatingBar object and setup listener for it, you can use simple interface callback or lambda

  1. var rate = findViewById<ExactRatingBar>(R.id.rate)
  2. rate.onRatingBarChanged = object : ExactRatingBar.OnRatingBarChanged{
  3. override fun newRate(rate: Float) {
  4. Toast.makeText(this@MainActivity, rate.toString(), Toast.LENGTH_LONG).show()
  5. Log.d("MYTAG", "interface$rate")
  6. }
  7. }
  8. rate.onRateChanged = {
  9. Log.d("MYTAG", "lambda$it")
  10. }

You can set properties of RatingBar in xml

  1. <uz.jamshid.library.ExactRatingBar
  2. android:id="@+id/rate"
  3. android:layout_width="wrap_content"
  4. android:layout_height="wrap_content"
  5. android:layout_gravity="center"
  6. app:starCount="5"
  7. app:isIndicator="false"
  8. app:starFillColor="@color/colorAccent"
  9. app:starSize="96"
  10. app:starValue="3.5"
  11. ></uz.jamshid.library.ExactRatingBar>

starCount specifies number of stars

isIndicator enables/disables touch listener, by which user enables or disables seeking in RatingBar

starFillColor color of star

starSize size of star

starValue rate of star, e.g 3.5 out of 5