18

ratingbar didn't change when the user click on it ?

her is my xml code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.soulhis.testmaterialdesign.Test">
<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/ratingBar4"
    android:layout_centerVertical="true"
    style="?android:attr/ratingBarStyleSmall"
     android:layout_centerHorizontal="true" />
 </RelativeLayout>

the problem occur just when using ratingBarStyleSmall tested on android jellybean api level 17

soulhi salah
  • 399
  • 1
  • 4
  • 11

7 Answers7

33

so I had the same issue and I put android:isIndicator="false" to my RatingBar tag and it solved the problem for me now my full rate bar tag looks like this:

<RatingBar
    android:id="@+id/ratingReview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:numStars="5"
    android:isIndicator="false"
    style="@style/Base.Widget.AppCompat.RatingBar"/>

hope this helps. for more info you can refer to this answer too.

Pouya Danesh
  • 1,557
  • 2
  • 19
  • 36
20

Just add

android:isIndicator="false"
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Sharanjeet Kaur
  • 796
  • 13
  • 18
12

It is defined behavior of RatingBar. According to official documentation, "The smaller RatingBar style ( ratingBarStyleSmall) and the larger indicator-only style (ratingBarStyleIndicator) do not support user interaction and should only be used as indicators."

Alex
  • 617
  • 4
  • 15
6

Note:
1. RatingBar Selection Enable - android:isIndicator="false"
2. No. of Stars - android:max="5"
3. Increment the star selection by 1 - android:stepSize="1"
4. this is important - android:layout_width="wrap_content"
5. Align rating bar to center horizontally - android:layout_gravity="center_horizontal"

<RatingBar
                android:id="@+id/ratingBarOutlet"
                android:layout_width="wrap_content"   
                android:layout_height="wrap_content"
                android:isIndicator="false"           
                style="?android:attr/ratingBarStyle"  
                android:max="5"                      
                android:layout_gravity="center_horizontal" 
                android:stepSize="1" />
Manoj Selvin
  • 2,247
  • 24
  • 20
3

Properly Working example and no need to remove style="?android:attr/ratingBarStyle"...

      <RatingBar
        style="?android:attr/ratingBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:isIndicator="false"
        android:numStars="5"
        android:stepSize="0.5" />
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
2

by this line style="?android:attr/ratingBarStyleSmall" your rating bar is not working. remove this it will work.

Lovekush Vishwakarma
  • 3,035
  • 23
  • 25
1

android:isIndicator="false"

is work

Khaled Inf
  • 49
  • 1