Skip to content Skip to sidebar Skip to footer

Cut Off Image In Ratingbar

I made own ratingbar. There are 4 sizes of flowers images (xdpi, hdpi, etc) from 24pxx24px to 64x64px. Copy

from TableRow as it causes a padding just above the flower drawable.


Solution 2:

In the XML of your rating bar change

android:layout_height="wrap_content"

to

android:layout_height="[some number]sp".

This will resolve the issue of cut off images.

DisplayMetrics can be used to get general information about a display and then figure out the appropriate units to use, but using an android unit converter is a lot simpler though.


Solution 3:

Use the style as a ?android:attr/ratingBarStyleSmall

<RatingBar
android:id="@+id/rating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:progressDrawable="@drawable/ratingbar_selector"
android:rating="2.0"
android:stepSize="1.0" />

and the custom rating bar selector will be: ratingbar_selector.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@android:id/background"
        android:drawable="@drawable/ic_unselected_star" />
    <item
        android:id="@android:id/secondaryProgress"
        android:drawable="@drawable/ic_unselected_star" />
    <item
        android:id="@android:id/progress"
        android:drawable="@drawable/ic_selected_star" />
</layer-list>

IMP Note: If Custom rating bar icon size is like 48x48, 50x50 etc then put the icon into xxhdpi folder(Because i used smaller(36x36) rating icon and that was creating same issue). then I used rating bar icon which size is 48x48.


Solution 4:

I ran into the exact same issue here. For me, the problem was not in the code, but in the images itself. In my case, the solution was to adjust the photos to manually be the sizes I wanted (IE 24x24 or 64x64) and put them into the right folders.

I tried multiple things, but it seems like the

<item name="android:minHeight">24dip</item>
<item name="android:maxHeight">64dip</item>

Bit of code for me would not do anything. Try resizing the images themselves and see if that fixes it.

-Sil


Solution 5:

set android:layout_height="0dp"

https://stackoverflow.com/a/44992485/4238544


Post a Comment for "Cut Off Image In Ratingbar"