不一致的评级栏进度色调

时间:2015-07-31 04:02:23

标签: android android-layout

我的布局中添加了RatingBar:

{{1}}

正如您所看到的,我已将进度色调设置为黄色(#FFEB3B)。现在在我的设备(Nexus 5)上,评级栏进度实际上是黄色的,我的问题是其他设备上的进度颜色变化。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

所以最后我通过创建自己的进度绘制来解决我的问题:

ratingstars_small.xml file

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:id="@android:id/background"
       android:drawable="@mipmap/icon_rate_empty" />
   <item android:id="@android:id/secondaryProgress"
       android:drawable="@mipmap/icon_rate_empty" />
   <item android:id="@android:id/progress"
       android:drawable="@mipmap/icon_rate_full" />
</layer-list>

并在我的评级栏xml:

<RatingBar
   android:id="@+id/rb"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:numStars="5"
   android:layout_weight="1"
   android:layout_gravity="right"
   style="?android:attr/ratingBarStyleSmall"
   android:progressDrawable="@drawable/ratingstars_small"/>

对于自定义图像,这些是尺寸:

对于样式style="?android:attr/ratingBarStyleSmall"

mdpi: 16px
hdpi: 24px
xhdpi: 32px
xxhdpi: 48px

和样式style="?android:attr/ratingBarStyleIndicator"

mdpi: 35px
hdpi: 52px
xhdpi: 69px
xxhdpi: 105px

我希望那些有同样问题的人发现这非常有用。

相关问题