Skip to content

Jamshid-M/ExactRatingBar

Repository files navigation

ExactRatingBar

Android Arsenal

RatingBar with exact values.

Usage

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

repositories {

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

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

        var rate = findViewById<ExactRatingBar>(R.id.rate)
        rate.onRatingBarChanged = object : ExactRatingBar.OnRatingBarChanged{
            override fun newRate(rate: Float) {
                Toast.makeText(this@MainActivity, rate.toString(), Toast.LENGTH_LONG).show()
                Log.d("MYTAG", "interface$rate")
            }
        }

        rate.onRateChanged = {
            Log.d("MYTAG", "lambda$it")
        }

You can set properties of RatingBar in xml

<uz.jamshid.library.ExactRatingBar
        android:id="@+id/rate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:starCount="5"
        app:isIndicator="false"
        app:starFillColor="@color/colorAccent"
        app:starSize="96"
        app:starValue="3.5"
        />

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