1

これは半角でも表示されません!もちろん、私は他のすべての質問を準備している、彼らは試していない魔法を含んでいない。Android RatingBar ratingBarStyleSmallは完全な/塗りつぶされた星のみを表示します

私はスタイルを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を使用してい
enter image description here

。 私のcompileSdkVersiontargetSdkVersionはともに23です。 Android 5.0デバイスでテストしています。

+0

ステップサイズ0.5を使用してチェックしてください。 – Vickyexpert

答えて

4

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

Rating bar with partial star

私は唯一の3色を変更:これは私が得るものです。背景色合いはまったく使用されていないようです(AppCompat 23.4.0、API 22デバイス)。

+0

これは非常に役に立ちました!ちょうどこれを完了するために。 blue/secondaryProgressTintを消したい場合。 100%透過色の#00000000を使用します。または不透明度が0の黒色の色が正しいと判断します。 – Nulle

関連する問題