2011-03-18 50 views
5

我终于找到了如何更改ratingBar的图像,但我无法弄清楚如何更改大小。我有这个android ratingbar size

<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> 

但每当我在minHeightmaxHeight改变它的大小保持不变。

我的布局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> 

我在做什么错?

谢谢您的帮助

+0

邮政布局XML。 – 2011-03-18 16:50:44

回答

2

我有同样的奇怪的问题,当我切换从1.6到2.1。在样式取出小词,并尝试:

android:style/Widget.RatingBar.Small 

android:style/Widget.RatingBar 
8

变化从

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

样式到

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

欲了解更多信息,请参见下面的特别是从6开始的评论。

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

+0

当我这样做时,我得到一个错误:“非法资源参考:@ * android资源是私人的,并不总是存在” – tomsv 2014-06-09 15:23:56

6

一个解决方案包括在应用规模的属性,你的RatingBar,因此它不是真正精确:

 <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> 

明星较小和互动仍然有效

+1

规模属性实际上并没有改变评级栏的大小。 – drspaceboo 2013-01-08 04:52:32