编辑: 我删除了该行
<item
android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/ratingbar_full_empty_sc"/>
它消除了不良影响。所以这确实是一个超级问题。现在给半分的感觉是很笨拙的。有人有真正的解决方案吗?请...
原帖
我尝试实现一个评级栏,但我对半满的有一些问题。我修改现有代码并关注这篇文章
这是奇怪的结果:
听说过这个问题吗?
我在下面发布我的代码
<RatingBar
android:id="@+id/rating_view"
style="@style/sc_rating_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_medium" />
评分栏样式:
<style name="sc_rating_bar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/ratingbar_full_sc</item>
</style>
进度绘图:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+android:id/background"
android:drawable="@drawable/ratingbar_full_empty_sc"/>
<item
android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/ratingbar_full_empty_sc"/>
<item
android:id="@+android:id/progress"
android:drawable="@drawable/ratingbar_full_filled_sc"/>
</layer-list>
ratingbar_full_empty_sc :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/star_empty2" android:state_pressed="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2" android:state_focused="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2" android:state_selected="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/star_empty2"/>
</selector>
而他的兄弟 ratingbar_full_filled_sc 和 image 完全一样star_full2
。
我做错了什么 ?你可以在我的截图上看到两张图片,一张是满的星,一张是空的。