quite simple, do a XML layout like this:
FrameLayout
View // background set to be a custom drawable
TextView // gravity right
in code you inflate it and set the drawable:
private CustomDrawable drawable;
drawable = new CustomDrawable(context);
View v = layout.findViewById(...
v.setBackground(drawable);
then to update the percentage
drawable.setLevel(10); // for 10% for example
when you create your custom drawble inside the draw method it's a simple call to drawRect
{
canvas.drawRect(0, 0, getLevel()/100*canvas.getWidth(), canvas.getHeight, paint);
}
the paint
you create with the color you want it to be.
That's a very rough idea, but I hope it's enough to guide you to the correct direction.