I do have read how to make custom rating bar from here. But I want to make rating bar that retrieve image from the server.
Does it possible ? How ?
I do have read how to make custom rating bar from here. But I want to make rating bar that retrieve image from the server.
Does it possible ? How ?
it may be not the exact but definitely serve for your purpose with slight add on codes .
Here is the sample code
RatingBar mRatingBar = (RatingBar) findViewById(R.id.ratingbar);
mRatingBar.setStarEmptyDrawable(getResources().getDrawable(R.mipmap.star_empty));
mRatingBar.setStarHalfDrawable(getResources().getDrawable(R.mipmap.star_half));
mRatingBar.setStarFillDrawable(getResources().getDrawable(R.mipmap.star_full));
mRatingBar.setStarCount(5);
mRatingBar.setStar(2.5f);
mRatingBar.halfStar(true);
mRatingBar.setmClickable(true);
mRatingBar.setStarImageWidth(120f);
mRatingBar.setStarImageHeight(60f);
mRatingBar.setImagePadding(35);
mRatingBar.setOnRatingChangeListener(
new RatingBar.OnRatingChangeListener() {
@Override
public void onRatingChange(float RatingCount) {
Toast.makeText(MainActivity.this, "the fill star is" + RatingCount, Toast.LENGTH_SHORT).show();
}
}
);
You can use your own image from server in setStars . All you need to do is to convert your image from server into a drawable
Here is the gradle
compile 'com.hedgehog.ratingbar:app:1.1.2'
For a detailed explanation and updated version use this github-link
Please give it a try and let me know your comments