简体   繁体   English

Android RatingBar ratingBarStyleSmall仅显示完整/填充星标

[英]Android RatingBar ratingBarStyleSmall only show full/ filled stars

It doesn't even show any half star! 它甚至没有显示任何半星! Of course, I've ready all the other questions, they contain no magic I haven't tried. 当然,我已准备好所有其他问题,它们没有任何魔法,我没有尝试过。

I tried changing the style to ratingBarStyle and there is half star but of course, normal size RatingBar does not meet my requirements here. 我尝试将样式更改为ratingBarStyle并且有半星但当然,正常大小的RatingBar不符合我的要求。

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <RatingBar
            android:id="@+id/ratingBar2"
            style="?android:attr/ratingBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:isIndicator="true"
            android:backgroundTint="@color/colorAccent"
            android:progressTint="@color/colorAccent"
            android:secondaryProgressTint="@color/colorAccent"
            android:numStars="5"
            android:rating="3.3"
            android:stepSize="0.1"/>
    </LinearLayout>

My Java code: 我的Java代码:

ratingBar.setStepSize(0.1f);
ratingBar.setRating(3.5f);

Result I'm seeing: 结果我看到:
在此输入图像描述

I'm using Android Support version 23.4.0. 我正在使用Android支持版本23.4.0。 My compileSdkVersion and targetSdkVersion are both 23. I'm testing on a Android 5.0 device. 我的compileSdkVersiontargetSdkVersion都是23.我正在Android 5.0设备上测试。

Remove or change the android:secondaryProgressTint . 删除或更改android:secondaryProgressTint It is used to fill the last (partial) star. 它用于填充最后(部分)恒星。 This is what I get with : 这是我得到的:

    <RatingBar
        android:id="@+id/ratingBar2"
        style="?android:attr/ratingBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:isIndicator="true"
        android:backgroundTint="#f00"
        android:progressTint="#0f0"
        android:secondaryProgressTint="#00f"
        android:numStars="5"
        android:rating="3.3"
        android:stepSize="0.1"/>

评分栏与部分明星

I only changed the 3 colors. 我只改变了3种颜色。 It seems that the background tint is not used at all (AppCompat 23.4.0, API 22 device). 似乎根本没有使用背景色调(AppCompat 23.4.0,API 22设备)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM