Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android ratingbar size

Tags:

android

layout

I have finally found out how to change images of the ratingBar, but I can't figure out how to change the size. I have this

<resources>
    <style name="foodRatingBarSmall" parent="@android:style/Widget.RatingBar.Small">
        <item name="android:progressDrawable">@drawable/rating_bar_used</item>
        <item name="android:minHeight">10dip</item>
        <item name="android:maxHeight">10dip</item>
    </style>
</resources>

But whenever i change the size in the minHeight and maxHeight it remains the same.

My layout xml:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:onClick="showRecipeOnClick" android:clickable="true" style="@style/row">

    <TableRow
            android:id="@+id/tableRow1" android:layout_gravity="center" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center_vertical">
        <TextView android:id="@+id/customName"
            android:textSize="25px"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView"
            android:textColor="@color/black"
            android:layout_weight="5">
        </TextView>
        <RatingBar android:id="@+id/mainRatingBar"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:numStars="5"
                   android:stepSize="0.5"
                   android:isIndicator="true"
                   android:layout_gravity="center_vertical"
                   style="@style/foodRatingBarSmall"></RatingBar>
    </TableRow>
        <View android:layout_width="fill_parent"
            android:layout_height="2dip"
            android:background="@color/black"/>
    </TableLayout>

What am I doing wrong?

Thank you for your help

like image 981
Bastaix Avatar asked Mar 18 '11 16:03

Bastaix


3 Answers

Change the Style from

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

to

parent="@*android:style/Widget.RatingBar.Small"

For more information see the below link especially the comment from 6 onwards.

http://code.google.com/p/android/issues/detail?id=18659

like image 128
ReachmeDroid Avatar answered Nov 16 '22 00:11

ReachmeDroid


A solution consists in applying the scale attribute to your RatingBar, thus it's not really precise :

        <RatingBar android:id="@+id/mainRatingBar"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:numStars="5"
               android:stepSize="0.5"
               android:isIndicator="true"
               android:layout_gravity="center_vertical"
               style="@style/foodRatingBarSmall"
               android:scaleX="0.8"
               android:scaleY="0.8"></RatingBar>

Stars are smaller and interaction still works

like image 22
ugo Avatar answered Nov 15 '22 23:11

ugo


I am having the same weird problem when I switched from 1.6 to 2.1. Remove the small word in your style and try:

android:style/Widget.RatingBar.Small

to

android:style/Widget.RatingBar
like image 34
SaKet Avatar answered Nov 15 '22 23:11

SaKet