![](/img/trans.png)
[英]Android RatingBar ratingBarStyleSmall only show full/ filled stars
[英]ratingbar cannot show only full stars
弄糟的是视图的宽度。 我弄乱了一点,似乎10个星太宽了,无法在屏幕上全部显示。 这弄乱了视图。 如果尝试将其置于横向模式,则会注意到它会起作用。 您要么必须在横向上这样做,要么要拥有较少或较小的星星,以使它们适合屏幕的宽度。
尝试这个 。
默认情况下,您的RatingBar
星级更大。
在RatingBar
使用style="@style/Widget.AppCompat.RatingBar.Small"
删除android:layout_weight="1"
<RatingBar
android:id="@+id/ratingBar"
style="@style/Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="10"
android:rating="2.5"
android:stepSize=".5"/>
Android不会调整RatingBar中的星星大小。请在评分栏中使用自定义样式来调整评分栏的大小。
<style name="MyRatingBar" parent="@android:style/Widget.DeviceDefault.RatingBar.Indicator">
<item name="android:minHeight">48dp</item>
<item name="android:maxHeight">48dp</item>
</style>
然后将该样式添加到评分栏
<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="10"
android:stepSize="1.0"
android:max="10"
style="@style/MyRatingBar" />
有关此问题的更多信息,请参见此处http://web.archive.org/web/20160323223259/http://kozyr.zydako.net/2010/05/23/pretty-ratingbar/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.