我的应用程序中有简单的 RatingBar
。我设置了 numStarts="5"
但它显示超过 5 星。当我设置 ndroid:layout_width="match_parent"
时,我尝试了几个教程,但也没有用,根据 numStarts
doc 显示启动次数,但在我的情况下,它不起作用。我浏览了 doc 和几个教程,但没有得到任何解决方案。
但我只想在评级栏中给 5 星。
我的评分栏如下。
<RatingBar
style="@style/customRatingBar"
android:id="@+id/course_rating_bar"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:numStars="5"
android:isIndicator="false"
android:stepSize="1.0"/>
这是我的自定义样式
<style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/ratingstars</item>
<item name="android:minHeight">22dip</item>
<item name="android:maxHeight">22dip</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/star_empty" />
<item android:id="@+android:id/secondaryProgress"
android:drawable="@drawable/star_empty" />
<item android:id="@+android:id/progress"
android:drawable="@drawable/star" />
</layer-list>
最佳答案
你必须设置 android:layout_width="wrap_content"而不是 "match_parent"。然后你会得到5星。
关于rating - Android RatingBar numStart 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32264414/