I'm working on this feedback screen where I have to implement a custom rating bar. After doing some research I found this method to be just what I need. At this point I'm getting two different rating bar in an overlaying manner. I want to hide the default rating bar provided by android and I know why its happening. I'm not able to hide the rating bar. I tried getProgressDrawable().setVisible(false, false)
but its of no use.
Here is the code of my overridden onDraw(Canvas c);
method:
@Override
protected synchronized void onDraw(Canvas canvas)
{
int stars = getNumStars();
float rating = getRating();
try
{
bitmapWidth = getWidth() / stars;
}
catch (Exception e)
{
bitmapWidth = getWidth();
}
float x = 0;
for (int i = 0; i < stars; i++)
{
Bitmap bitmap;
Resources res = getResources();
Paint paint = new Paint();
if ((int) rating > i)
{
bitmap = BitmapFactory.decodeResource(res, R.drawable.filled_star);
}
else
{
bitmap = BitmapFactory.decodeResource(res, R.drawable.unfilled_star);
}
Bitmap scaled = Bitmap.createScaledBitmap(bitmap, getHeight(), getHeight(), true);
canvas.drawBitmap(scaled, x, 0, paint);
paint.setColor(Color.WHITE);
paint.setTextSize(20f);
canvas.drawText(String.valueOf(i), x+33, 83, paint);
canvas.save();
x += bitmapWidth;
}
super.onDraw(canvas);
}
I just want to hide the android default rating bar overlaying on my custom rating bar.
Thanks!