How to apply rating bar in android

Step 1 :

Put below code in your layout file :

<RatingBar    android:id="@+id/ratingBar"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_gravity="center"    android:numStars="5"    android:progressTint="@android:color/holo_orange_light"    android:layout_marginTop="10dp"    android:stepSize="1.0"    android:rating="0" />


here define the components which we are used :

ratingBar - id of RatinBar Component.

numStars - how many starts which you show for rating

progressTint  - Color of starts when we select for rating.

stepSize - when we click one time how may count we measure.

rating  - initial rating which we show on rating bar.


When we are using this RatingBar in Activity class so following methods are useful.

setRating - for any rating.

getRating  - get the current rating from the RatingBar.

Share this

Related Posts

Previous
Next Post »