How to remove padding from Rating Bar in Android?

Viewed 3112

i have rating bar on my application and it appears like this:

enter image description here

I've tried to set padding to 0dp, but nothing changed to the view.

 <RatingBar
      android:id="@+id/ratingBar"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:numStars="5"
      android:layout_marginStart="16dp"
      android:isIndicator="false"
      style="@style/Widget.AppCompat.RatingBar"/>

Expected result: I am expecting the rating bar with no right padding and bottom padding.

5 Answers

You can simply adjust this

style="@android:style/Widget.DeviceDefault.RatingBar.Small"

instead of

style="@style/Widget.AppCompat.RatingBar

I add this to my xml code and it solved my problems:

android:scaleX="1"
android:scaleY="1"

use scale x and y to reduce the start size and step size to set star size

Try this xml code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">

<RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:numStars="5"
    android:isIndicator="false"
    style="@style/Widget.AppCompat.RatingBar" />
</LinearLayout>
Related