2016-08-21 67 views
2

我想设置为小进度自定义颜色与此代码的颜色:如何设置的Android小的RatingBar的

<style name="RatingBar" parent="Theme.AppCompat"> 
     <item name="colorControlNormal">@color/gold_yellow</item> 
     <item name="colorControlActivated">@color/light_grey</item> 
    </style> 




<RatingBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:isIndicator="true" 
     android:rating="3.3" 
     android:theme="@style/RatingBar" 
     android:id="@+id/go_rating" 
     style="@android:style/Widget.Holo.Light.RatingBar.Small"/> 

这个问题是这样的:明星小相当好的,但他们是蓝色的。但是,如果我删除style="@android:style/Widget.Holo.Light.RatingBar.Small那么颜色变成金黄色,但它变得很大。

请如何为恒星设置自定义颜色并同时使其变小?

回答

8

使用style="?attr/ratingBarStyleSmall"风格:

<RatingBar 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:isIndicator="true" 
    android:rating="3.3" 
    android:theme="@style/RatingBar" 
    android:id="@+id/go_rating" 
    style="?attr/ratingBarStyleSmall"/> 

还看到:https://stackoverflow.com/a/3173594/5183999

+0

谢谢!你做到了!我一直在为此挣扎3个多小时。谢谢! – X09

+0

我很乐意帮忙;)你能标记答案已经提出吗? – nshmura

+0

是的,我已经做到了。 – X09