How to disable the blinking color/animations on other stars when one is clicked?

Viewed 94

When I click on a star, the other stars are blinking before it gets full blue, I want to disable the dancing effect/animation/background color or whatever of the other stars when the respective stars are clicked. If anyone helps me to find a way to save time, it is most appreciated.

[<RatingBar
    android:id="@+id/rating_bar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_marginBottom="8dp"
    android:numStars="5"
    android:stepSize="1"
    app:layout_constraintBottom_toTopOf="@+id/btnSubmit"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.497"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/HiddenText"
    app:layout_constraintVertical_bias="0.488" />][1]

**When I click on a star, the other stars are blinking with the accent color of the filled star before it gets filled.**enter code here

rating_bar.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
/*
                Log.i(TAG, "onTouch:1111111 " +rating_bar.getRating());
*/
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    // TODO perform your action here
                    String StarPosition = String.valueOf(rating_bar.getRating());
                    if (StarPosition.equalsIgnoreCase("1.0")) {
                        HiddenText.setText("Poor");
                        HiddenText.setTextColor(Color.parseColor("#2F8E33"));

                    } else if (StarPosition.equalsIgnoreCase("2.0")) {
                        HiddenText.setText("Bad");
                        HiddenText.setTextColor(Color.parseColor("#2F8E33"));
                    } else if (StarPosition.equalsIgnoreCase("3.0")) {
                        HiddenText.setText("Average");
                        HiddenText.setTextColor(Color.parseColor("#2F8E33"));

                    } else if (StarPosition.equalsIgnoreCase("4.0")) {
                        HiddenText.setText("Good");
                        HiddenText.setTextColor(Color.parseColor("#2F8E33"));
                    } else if (StarPosition.equalsIgnoreCase("5.0")) {
                        HiddenText.setText("Excellent");
                        HiddenText.setTextColor(Color.parseColor("#2F8E33"));

                    } else {
                        HiddenText.setText("");

                    }

                    Log.i(TAG, "onTouch:2222222222 " + rating_bar.getRating());
                }
                return false;
            }
        });
1 Answers

instead of using OnTouchListener use OnRatingBarChangeListener

rating_bar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

    @Override
    public void onRatingChanged(RatingBar ratingBar, float rating,
            boolean fromUser) {
        //your code in here
        if(rating < 0.5f) {} // no rating or 0 stars, not filled?
        else if(rating < 1.5f) {} // one star (rounded)
        else if(rating < 2.5f) {} // two starts (rounded)
        else...
    }
});
Related