我对 ratingBar 的自定义样式有疑问?
03-26 15:22:12.229: E/AndroidRuntime(2075): FATAL EXCEPTION: main
03-26 15:22:12.229: E/AndroidRuntime(2075): android.view.InflateException: Binary XML file line #54: Error inflating class android.widget.RatingBar
03-26 15:22:12.229: E/AndroidRuntime(2075): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
03-26 15:22:12.229: E/AndroidRuntime(2075): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-26 15:22:12.229: E/AndroidRuntime(2075): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
......
03-26 15:22:12.229: E/AndroidRuntime(2075): Caused by: java.lang.NumberFormatException: unable to parse 'res/drawable/ratingbar_yellow.xml' as integer
我的 ratingbar_yellow.xml
<item
android:id="@+android:id/background"
android:drawable="@drawable/rate_star_small_off"/>
<item
android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/rate_star_small_half"/>
<item
android:id="@+android:id/progress"
android:drawable="@drawable/rate_star_small_on"/>
我的风格
<style name="yellowRatingBarSmall" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/ratingbar_yellow</item>
<item name="android:secondaryProgress">@drawable/ratingbar_yellow</item>
<item name="android:minHeight">14dip</item>
<item name="android:maxHeight">14dip</item>
<item name="android:isIndicator">true</item>
<item name="android:indeterminateOnly">false</item>
</style>
在我的布局中
<RatingBar
android:id="@+id/restaurant_rating"
style="@style/yellowRatingBarSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>