I wanted to make a rounded shape and apply it as a background on a layout. This i have under control, but i wanted to make the background like a progressbar.
that is i want it to look something like this image:
I want to be able to control where the bg change so i guess it should be done in code. It must be done in a way so i can place text over it
at the moment i have this code for creating a rounded corner shape:
int w = this.getWidth() - this.getPaddingLeft() - this.getPaddingRight();
int 开发者_StackOverflow中文版h = this.getHeight() - this.getPaddingTop() - this.getPaddingBottom();
int progressWidth = Math.round((w * percent) / 100);
ShapeDrawable shapeDrawable = new ShapeDrawable();
float[] outerR = new float[]{5, 5, 5, 5, 5, 5, 5, 5};
RectF inset = new RectF(0, 0, 0, 0);
float[] innerR = new float[]{0, 0, 0, 0, 0, 0, 0, 0};
RoundRectShape roundRectShape = new RoundRectShape(outerR, inset, innerR);
shapeDrawable.setShape(roundRectShape);
shapeDrawable.getPaint().setColor(progressColor);
shapeDrawable.setBounds(0,0,w,h);
精彩评论