2016-08-21 27 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