0

I need to separate the stars in a RatingBar, it's possible? Or have I to create my own RatingBar?

<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:numStars="7"
    android:id="@+id/estrellas2"
    android:scaleX="1.2"
    android:scaleY="1.2"
    android:layout_below="@+id/textView2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="30dp"/>
Anil
  • 1,605
  • 1
  • 14
  • 24

2 Answers2

0

Set

android:progressDrawable="@drawable/custom_ratingbar_selector"

property to customize rating bar .

and

Create custom_ratingbar_selector.xml in drawable and paste this code

<?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/unslected_star_icon" />

    <item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/unslected_star_icon" />

    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/slected_star_icon" />

</layer-list>
Adeel
  • 2,901
  • 7
  • 24
  • 34
Nawrez
  • 3,314
  • 8
  • 28
  • 42
0

Try this code,
android:progressDrawable = "@drawable/rat_star"
android:indeterminateDrawable = "@drawable/rat_star"

@drawable/rat_star :

<?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/starempty" />
    <item android:id="@+android:id/secondaryProgress"
          android:drawable="@drawable/starempty" />
    <item android:id="@+android:id/progress"
          android:drawable="@drawable/star" />
</layer-list>
Pratik18
  • 365
  • 1
  • 7