Skip to content

Instantly share code, notes, and snippets.

@defHLT
Last active August 29, 2015 14:19
Show Gist options
  • Save defHLT/a721649c79e3a2164392 to your computer and use it in GitHub Desktop.
Save defHLT/a721649c79e3a2164392 to your computer and use it in GitHub Desktop.
mRatingView = view.findViewById(R.id.rating_view);
mRatingClip = (ClipDrawable) mRatingView.getBackground();
BitmapDrawable star = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_fab_star);
Bitmap bitmap = star.getBitmap();
int side = bitmap.getHeight();
ViewGroup.LayoutParams lp = mRatingView.getLayoutParams();
lp.width = side * 10;
lp.height = side;
/*
ratingLevel is [0; 10]
ClipDrawable takes values from [0; 10e3]
*/
float ratingRound = Math.round(ratingLevel / 0.5) * 0.5f;
mRatingClip.setLevel((int) (1000 * ratingRound));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment