繁体   English   中英

Android评分栏中的StepSize

[英]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)。

StepSize也设置为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”调整您的ratingBar,这会考虑您的步长并采用十进制评级。

你最好在这里得到它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM