【发布时间】:2015-10-08 13:08:22
【问题描述】:
我在我的应用程序中显示评级栏,我想减小星的尺寸。 所以这里是评分栏的xml
<RatingBar
android:id="@+id/ratingBar"
style="?android:attr/ratingBarStyleSmall"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:max="5"
android:stepSize="0.25"
android:numStars="0"
android:focusable="false"
android:layout_gravity="center_horizontal"
android:focusableInTouchMode="false"
android:isIndicator="true"/>
我正在像这样设置颜色和评级
private RatingBar ratingBar;
Drawable ratingBarColor = ratingBar.getProgressDrawable();
ratingBar = (RatingBar) view.findViewById(R.id.ratingBar);
Drawable ratingBarColor = ratingBar.getProgressDrawable();
ratingBar.setRating((float) (value));
DrawableCompat.setTint(ratingBarColor, ContextCompat.getColor(getActivity(), R.color.red));
但问题是无论任何值,颜色和小数填充都不起作用。我正在使用样式来减少星尺寸。奇怪的是,如果我在 xml 中删除 style 属性,它将设置为精确值为星,但尺寸将重置为默认值。如果我将最小/最大高度添加到星形,图像将被裁剪。
这是同样的问题:-How to set the custom size of the stars in RatingBar
试过:style="?android:attr/ratingBarStyleIndicator" 仍然是同样的问题。
我不明白 style 属性有什么问题。
【问题讨论】:
-
缩小星图尺寸
-
颜色未根据值填充。如果我减小图像被裁剪的尺寸。请参阅链接的问题。
-
maxsize 和 minsize 等于星图大小而不是图像不裁剪
-
那么图像尺寸在哪里减小?
-