在我的代码中,我想设置我的自定义星星,但它没有正常工作
<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:numStars="5"
android:stepSize="1"
android:rating="1"
android:progressDrawable="@drawable/rating_bar_color"/>
rating_bar_color.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/starw30" />
<item android:id="@android:id/progress" android:drawable="@drawable/star" />
</layer-list>
我使用这段代码以及我得到的结果
线条来自哪里。星星的大小与默认星星大小相同。
最佳答案
出现这些行是因为您正尝试使用 android:layout_height="wrap_content"
包裹评分栏图像。因此,作为一种解决方案,您必须根据图像的大小提供评分栏的高度。
如果评分栏图像的大小是20,那么尝试添加
android:layout_height="20dip"
这对你有用!
关于android - 评分栏星级不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20541169/