繁体   English   中英

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

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

它甚至没有显示任何半星! 当然,我已准备好所有其他问题,它们没有任何魔法,我没有尝试过。

我尝试将样式更改为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>

我的Java代码:

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

结果我看到:
在此输入图像描述

我正在使用Android支持版本23.4.0。 我的compileSdkVersiontargetSdkVersion都是23.我正在Android 5.0设备上测试。

删除或更改android:secondaryProgressTint 它用于填充最后(部分)恒星。 这是我得到的:

    <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"/>

评分栏与部分明星

我只改变了3种颜色。 似乎根本没有使用背景色调(AppCompat 23.4.0,API 22设备)。

暂无
暂无

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

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