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_gra开发者_运维问答vity="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
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
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
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
精彩评论