StepSize in Rating Bar Android


   <RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:numStars="5"
    android:stepSize="0.1"
    android:isIndicator="true"
    android:rating="3.1"
    />

如果我给出3.1至3.5的评级,则显示的评分仅为3.5。

我需要以精确值设置(例如:3.1)。

STEPIZE也设置为0.1。

请任何人在此帮助我。

预先感谢。

尝试这样的

  <RatingBar
    android:id="@+id/ratingBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:numStars="5"
    android:stepSize="1"
    />

    ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
        @Override
        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            if(rating == 1.0)
            {
                Toast.makeText(MainActivity.this, "3.1", Toast.LENGTH_SHORT).show();
            }
            else if(rating == 2.0)
            {
                Toast.makeText(MainActivity.this, "3.2", Toast.LENGTH_SHORT).show();
            }
        }
    });

尝试以下:

<android.support.v7.widget.AppCompatRatingBar
            android:id="@+id/rb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="10dp"
            android:isIndicator="false"
            android:numStars="6"
            android:stepSize=".1"
            app:secondaryProgressTint="#00000000"
            android:numStars="6"
           />

如果您在RatingBar中设置了secondaryProgressTint,它将与版本> = 21 一起使用。支持所有版本使用AppCompatRatingBar

尝试使用属性Android:width =" match_parent"调整评级栏 在您的父母布局中,这将牢记您的步骤,并以小数为十进制的评分。

您最好在这里得到它。

最新更新