Rating¶
Quick start¶
<com.ave.vastgui.tools.view.ratingview.RatingView
android:id="@+id/ratingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Mode¶
Add: Version 0.5.3 Update: Version 1.5.2
Rating currently supports three select method:
-
SLIDING
The rating can be set by sliding or calling
setStarRating. -
CLICK
Click behavior changes
Starting from version 0.5.6, when the select method is set to
Click, the selected number of stars can only be an integer.The rating can be set by clicking or calling
setStarRating. -
UNABLE
The rating can only be set by calling
setStarRating.
binding.ratingView.setStarTouchMode(RatingView.Mode.SLIDING)
<com.ave.vastgui.tools.view.ratingview.RatingView
...
app:star_touch_mode="click" />
Orientation¶
Add: Version 0.5.3 Update: Version 1.5.2
Rating currently supports two orientations:
- HORIZONTAL
- VERTICAL
binding.ratingView.setStarOrientation(RatingView.Orientation.HORIZONTAL)
<com.ave.vastgui.tools.view.ratingview.RatingView
...
app:star_orientation="horizontal" />
Interval width¶
The interval width between stars can be set by star_interval_width or calling setStarIntervalWidth .
binding.ratingView.setStarIntervalWidth(10f.DP)
<com.ave.vastgui.tools.view.ratingview.RatingView
...
app:star_interval_width="10dp" />
Image¶
For selected star images, it can be set by star_selected or calling setStarSelectedBitmap .
binding.ratingView.setStarSelectedBitmap(R.drawable.ic_star_normal)
<com.ave.vastgui.tools.view.ratingview.RatingView
...
app:star_selected="@drawable/ic_star_selected" />
For unselected star images, it can be set by star_unselected and setStarUnselectedBitmap .
binding.ratingView.setStarUnselectedBitmap(R.drawable.ic_star_unselected)
<com.ave.vastgui.tools.view.ratingview.RatingView
...
app:star_unselected="@drawable/ic_star_unselected" />
Size¶
Add: Version 0.5.3
The size of the star image can be set by star_width and star_height or calling setStarBitmapSize .
binding.ratingView.setStarBitmapSize(40F.DP, 40F.DP)
<com.ave.vastgui.tools.view.ratingview.RatingView
...
app:star_width="40dp"
app:star_height="40dp" />
Number¶
The number of star can be set by star_count or calling setStarCountNumber .
binding.ratingView.setStarCountNumber(4)
<com.ave.vastgui.tools.view.ratingview.RatingView
...
app:star_count="5" />
Listener¶
Add: Version 0.5.6
Register a listener by calling setOnStarRatingChangeListener to observe the rating changes.
binding.ratingView.setOnStarRatingChangeListener(object : RatingView.OnStarRatingChangeListener {
override fun onRatingChanged(rating: Float) {
logger.d("Current rating is $rating")
}
})