[英]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.