【问题标题】:RatingBar colour appears White after upgrading Google Play Services 7.5.0升级 Google Play 服务 7.5.0 后 RatingBar 颜色显示为白色
【发布时间】:2015-06-24 13:48:49
【问题描述】:

在升级到“com.google.android.gms:play-services:7.5.0”之前,我的应用程序运行良好。我在一个运行良好的活动中使用 RatingBar。但升级后,Ratingbar 颜色显示为白色。即使我尝试使用代码和布局更改颜色,但颜色显示为白色。但是当我触摸评分栏时,会出现一些绿色的评分栏。

代码:

<RatingBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/ratingBar"
    android:layout_gravity="center_horizontal"
    android:numStars="5"
    android:theme="@style/Theme.AppCompat.Light"
    android:stepSize="0.5"
    android:progressBackgroundTint="#ff048ec4"
    android:progressTint="#ff048ec4"
    android:progressBackgroundTintMode="multiply"
    android:progressTintMode="multiply" />

问题仅在于低于 Lollipop 的版本。 Lollipop 中没有问题,但在 Kitkat 和更低版本中,颜色显示为白色。

有人知道这个问题的解决方案吗? 提前致谢。

【问题讨论】:

    标签: android android-widget google-play-services ratingbar


    【解决方案1】:

    For API &gt;= 21

    Drawable progress = ratingBar.getProgressDrawable();
    DrawableCompat.setTint(progress, Color.YELLOW);
    

    For API &lt; 21

    RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();
    stars.getDrawable(2).setColorFilter(Color.YELLOW,PorterDuff.Mode.SRC_ATOP);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多