1

How to fill ratingbar's stars from right to left ?

EDIT : I tried this :

android:align_right = "true"

but not works ... also tryin the deliverable

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

   <item android:id="@+android:id/background"
       android:drawable="@drawable/star_empty" />
   <item android:id="@+android:id/secondaryProgress"
       android:drawable="@drawable/star_empty" />
   <item android:id="@+android:id/progress"
       android:drawable="@drawable/star_fill" />
</layer-list>

swapping star_fill and star_empty also did nothing

Sina Miandashti
  • 2,087
  • 1
  • 26
  • 40

3 Answers3

9

A very simple way is adding

android:supportsRtl="true"

to android manifest in application tag. Remember that it will only work in API 17 and later.

Another hacky way is to add

android:rotation="180"

android:scaleY="-1" // this will flip the view vertically

Finally if you do not like any of above solutions you can play tricks with displaying drawables and use reverse calculations.

for example if the rating is 3/5 you can show it 2/5 with inverse image drawables.

Community
  • 1
  • 1
moallemi
  • 2,448
  • 2
  • 25
  • 28
3

try that

android:rotationY="180"

0

I think rotation="180" is a good trick. Also, you can use scaleY="-1" to flip each view vertically (and scaleX="-1" for horizontal). This trick will fix the upside-down problem.

imaN NeoFighT
  • 480
  • 4
  • 13