2017-07-31 8 views
0

私は自分のコードにRatingBarを追加しました。ステップサイズを0.1に設定しようとしていますが、デフォルトの0.5ステップサイズに応じて反応します。私は簡単にステップサイズを0.5より大きく設定することができ、意図したように反応しますが、それ以下では反応しません。Android:評価バーのステップサイズが0.5未満です。

私は理由を理解できませんか?私が考えることができるのは、RatingBarのステップサイズが0.5に制限されていることだけです。 RatingBarが最低限の星を描くのは理にかなっていませんか?

<android.support.v7.widget.AppCompatRatingBar 
    android:theme="@style/RatingBar" 
    android:stepSize="0.1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/ratingbar" 
    android:numStars="5" 
    android:rating="0.1" 
    style="?android:attr/ratingBarStyleSmall" 
    android:layout_below="@+id/title" 
    android:layout_centerHorizontal="true" /> 

上記のコードでは、星の半分が表示されます。しかし私の知識によると、星の10分の1を描くはずです。

P.S私はプログラムで実装しようとしましたが、それでも同じです。

答えて

0

secondaryProgressTintを透明な#00000000に設定することでこれを修正しました。

secondaryProgressTintは、開始された星の残りの部分を埋めます。デフォルトあたりの色は、プライマリprogressTintと同じ色に設定されているため、認識していない場合は混乱の原因となります。

<android.support.v7.widget.AppCompatRatingBar 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/ratingbar" 
      style="?android:attr/ratingBarStyleSmall" 
      android:isIndicator="true" 
      android:progressTint="@color/Red" 
      android:secondaryProgressTint="#00000000" 
      android:numStars="5" 
      android:rating="3.3" 
      android:stepSize="0.1" 
      android:layout_below="@+id/title" 
      android:layout_centerHorizontal="true" 
      /> 
関連する問題