I am trying to change the stars of my rating bar by creating new style, this what i did :
<style name="RatingBarSmall" parent="android:Widget.DeviceDefault.Light.RatingBar.Indicator">
<item name="android:progressDrawable">@drawable/rating_bar</item>
<item name="android:minHeight">36dp</item>
<item name="android:maxHeight">36dp</item>
</style>
drawable/rating_bar:
<?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/rating_star_empty" />
<item
android:id="@android:id/secondaryProgress"
android:drawable="@drawable/rating_star_empty" />
<item
android:id="@android:id/progress"
android:drawable="@drawable/rating_star_filled" />
</layer-list>
rating bar xml view:
<RatingBar
android:id="@+id/ratingBar"
style="@style/RatingBarSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:isIndicator="true"
android:rating="5" />
and here is the tow images:
but i don't know why i got vertical lines under the stars as you can see int the bellow picture:
EDIT: SOLVED:i just set the rating bar height as the image height.
thanks
I observe this problem in this way. You may create any values in res/values/dimens.xml
for each screen (mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi) like:
<dimen name="rating_min_height">36dp</dimen>
<dimen name="rating_min_width">36dp</dimen>
And use this:
<style name="RatingBarSmall" parent="android:Widget.DeviceDefault.Light.RatingBar.Indicator">
<item name="android:progressDrawable">@drawable/rating_bar</item>
<item name="android:minHeight">@dimen/rating_min_height</item>
<item name="android:maxHeight">@dimen/rating_min_width</item>
</style>
Or you can apply that logic to your drawable (rating_star_empty
and rating_star_filled
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With