Custom Android Rating Bar Stretch Image

I have a little problem when using custom bar style. I read other topics on this, but the proposed solutions / answers do not solve the problem.

Android seems to stretch part of the star image, creating this strange effect: bleeding

This strange effect is even noticeable in the eclipse graphic layout preview tool: bleeding2

Star "sprites": empty star and full star

This is custom style:

<style name="ratingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/rating_bar</item> <item name="android:minHeight">@dimen/ratingBarHeight</item> <item name="android:maxHeight">@dimen/ratingBarHeight</item> </style> 

And this is the xml code in the layout:

 <RatingBar android:layout_width="wrap_content" android:layout_height="@dimen/ratingBarHeight" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:numStars="5" android:stepSize="1.0" style="@style/ratingBar" /> 

The height is determined as follows:

 <dimen name="ratingBarHeight">32dip</dimen> 
+6
source share
1 answer

I had the same problem. The reason is because my drawable was smaller than @dimen/ratingBarHeight , it was 22 pixels. Changing @dimen/ratingBarHeight to 22dip fixed it for me, the weird effect disappeared.

+4
source

Source: https://habr.com/ru/post/921665/


All Articles