RatingBar主题只能在棉花糖中使用,而不能在棒棒糖中使用 [英] RatingBar Theme working in Marshmallow but not in Lollipop

查看:117
本文介绍了RatingBar主题只能在棉花糖中使用,而不能在棒棒糖中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码设置我的RatingBar的样式:

I am trying to style my RatingBar with the following code:

<style name="RatingBarfeed" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">@color/white</item>
    <item name="colorControlActivated">@color/duskYellow</item>
</style>

在layout.xml中,我使用以下代码:

And in layout.xml I am using the following code:

<android.support.v7.widget.AppCompatRatingBar
        android:theme="@style/RatingBarfeed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/ratingBarStyleSmall"
        android:id="@+id/ratingBar"
        android:paddingBottom="0.45dp"
        app:layout_constraintTop_toTopOf="@+id/rating"
        app:layout_constraintLeft_toRightOf="@+id/rating"
        app:layout_constraintBottom_toBottomOf="@+id/rating"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        android:background="@color/orange"
        android:rating="3.5"
        android:stepSize="0.5"/>

它可以在棉花糖中正常工作(请查看屏幕截图)

Its working fine in Marshmallow (check the screenshot)

但是在Lollipop中,主题无法正常工作(请查看屏幕截图)

But in Lollipop Theme is not working (check the screenshot)

请帮助... !!!!

Please Help...!!!!

推荐答案

经过艰苦的努力,我得到了答案: 它应该是style="@style/RatingBarfeed"而不是android:theme+"@style/RatingBarfeed"

After much struggle I got my answer: it should be style="@style/RatingBarfeed" instead of android:theme+"@style/RatingBarfeed"

对于样式星形填充,空白和部分颜色

For styling star fill, empty and partial color

android:progressTint="#F9BB28"
android:progressBackgroundTint="@color/white"
android:secondaryProgressTint="@color/white"

最终代码应该像

 <android.support.v7.widget.AppCompatRatingBar
        android:layout_width="wrap_content"
        android:layout_height="18dp"
        style="@style/RatingBarfeed"
        android:id="@+id/ratingBar"
        android:gravity="center"
        android:progressTint="#F9BB28"
        android:progressBackgroundTint="@color/white"
        android:secondaryProgressTint="@color/white"
        app:layout_constraintTop_toTopOf="@+id/rating"
        app:layout_constraintLeft_toRightOf="@+id/rating"
        app:layout_constraintBottom_toBottomOf="@+id/rating"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        android:background="@color/orange"
        android:rating="3.5"
        android:stepSize="0.1"/>

样式应为:

<style name="RatingBarfeed" parent="android:style/Widget.Material.RatingBar.Small">
    <item name="colorControlNormal">@color/white</item>
    <item name="colorControlActivated">@color/duskYellow</item>
</style>

这篇关于RatingBar主题只能在棉花糖中使用,而不能在棒棒糖中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆