I\'ve added a RatingBar in a layout:
Use This Code
<RatingBar
android:id="@+id/ratingBarSmalloverall"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="30dp"
android:isIndicator="false"
android:numStars="5" />
apply this.
<RatingBar android:id="@+id/indicator_ratingbar"
style="?android:attr/ratingBarStyleIndicator"
android:layout_marginLeft="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
although answer of Farry works, for Samsung devices RatingBar took random blue color instead of the defined by me. So use
style="?attr/ratingBarStyleSmall"
instead.
Full code how to use it:
<android.support.v7.widget.AppCompatRatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?attr/ratingBarStyleSmall" // use smaller version of icons
android:theme="@style/RatingBar"
android:rating="0"
tools:rating="5"/>
<style name="RatingBar" parent="Theme.AppCompat">
<item name="colorControlNormal">@color/grey</item>
<item name="colorControlActivated">@color/yellow</item>
<item name="android:numStars">5</item>
<item name="android:stepSize">1</item>
</style>
Just use:
android:scaleX="0.5"
android:scaleY="0.5"
Change the scale factor according to your need.
In order to scale without creating a padding on the left also add
android:transformPivotX="0dp"
the small one implement by the OS
<RatingBar
android:id="@+id/ratingBar"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<RatingBar
android:id="@+id/rating_bar"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />