7
我從this stackoverflow thread實現了自定義的評價欄未顯示即使我設置numStars 5不止一星或任何其他數量定製的RatingBar沒有表現出超過1星級
這裏是代碼。
我正在使用矢量繪圖的圖像。
的RatingBar在main_activity.xml
<RatingBar
android:id="@+id/ratingBarValue"
style="@style/Fuel_Indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:numStars="5"
android:stepSize="1.0"
android:max="5" />
Fuel_Indicator風格樣式。
<style name="Fuel_Indicator" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/fuel_bar_full</item>
<item name="android:indeterminateDrawable">@drawable/fuel_bar_full</item>
<item name="android:minHeight">23dip</item>
<item name="android:maxHeight">25dip</item>
</style>
的fuel_bar_filled.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"
android:drawable="@drawable/fuel_bar_empty" />
<item android:id="@android:id/secondaryProgress"
android:drawable="@drawable/fuel_bar_empty" />
<item android:id="@android:id/progress"
android:drawable="@drawable/fuel_bar_filled" />
fuel_bar_empty.xml
<selector
xmlns:android="http://schemas.android.com/apk/res/android">`
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_empty" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_empty" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_empty" />
<item android:drawable="@drawable/ic_fuel_empty" />
</selector>
fuel_bar_filled.xml
<selector
xmlns:android="http://schemas.android.com/apk/res/android">`
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_full" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_full" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/ic_fuel_full" />
<item android:drawable="@drawable/ic_fuel_full" />
</selector>
你爲什麼認爲他使用'SVG'? –
@VladMatvienko,因爲OP已經寫下了問題。對不起,它是'Vector Drawable'。 – Ironman
謝謝。它工作。我想知道Vector Drawable有什麼問題。 –