android - How to set vertical filled progress -
i want set custom circular progress-bar below:
edited
i wrote following code this. not work :
private void circularprogressbar(imageview iv2, int i) { bitmap b = bitmap.createbitmap(300, 300,bitmap.config.argb_8888); canvas canvas = new canvas(b); paint paint = new paint(); paint.setcolor(color.parsecolor("#c4c4c4")); paint.setstrokewidth(10); paint.setstyle(paint.style.stroke); canvas.drawcircle(150, 150, 140, paint); paint.setcolor(color.parsecolor("#ffdb4c")); paint.setstrokewidth(10); paint.setstyle(paint.style.fill); final rectf oval = new rectf(); paint.setstyle(paint.style.stroke); oval.set(10,10,290,290); canvas.drawarc(oval, 270, ((i*360)/100), false, paint); paint.setstrokewidth(0); // paint.settextalign(align.center); paint.setcolor(color.parsecolor("#8e8e93")); // paint.settextsize(140); // canvas.drawtext(""+i, 150, 150+(paint.gettextsize()/3), paint); iv2.setimagebitmap(b); }
thanks force me r&d , find out solution...
following code solution of given question
xml
<relativelayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <imageview android:id="@+id/imagegreenid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaletype="fitcenter" android:src="@drawable/clip_full_green_gauge" /> <imageview android:id="@+id/imagewhiteid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/clip_feil_empty_gauge" /> </relativelayout>
code in activity:
int total_percent = orininalscore * 100; int total_value = 10000; imageview img = (imageview) findviewbyid(r.id.imagegreenid); clipdrawable mimagedrawable = (clipdrawable) img.getdrawable(); mimagedrawable.setlevel(total_percent); imageview img1 = (imageview) findviewbyid(r.id.imagewhiteid); clipdrawable mimagedrawable1 = (clipdrawable) img1.getdrawable(); mimagedrawable1.setlevel(total_value - total_percent);
Comments
Post a Comment