3

I have this xml layer-list defined as my progressDrawable:

<item android:id="@android:id/background"
    android:useLevel="false">
    <shape
        android:innerRadius="@dimen/product_widget_progress_bar_inner_radius"
        android:shape="ring"
        android:thickness="@dimen/product_widget_progress_bar_thickness_normal"
        android:useLevel="false" >
        <solid android:color="@color/transparent" />
    </shape>
</item>
<item android:id="@android:id/progress" >
    <shape
        android:innerRadius="@dimen/product_widget_progress_bar_inner_radius"
        android:shape="ring"
        android:thickness="@dimen/product_widget_progress_bar_thickness_normal" >
        <solid android:color="@color/blue" />
    </shape>
</item>

The problem here is that I need the diameter to be variable (proportional to screen size).

So I tried to draw it programmatically. So far I've done this:

    GradientDrawable background = new GradientDrawable();
    background.mutate();
    background.setShape(GradientDrawable.RING);
    background.setColor(Color.TRANSPARENT);
    background.setUseLevel(false);


    GradientDrawable progress = new GradientDrawable();
    progress.mutate();
    progress.setShape(GradientDrawable.RING);
    progress.setColor(Color.BLUE);
    progress.setUseLevel(false); 

    ClipDrawable clipDrawable = new ClipDrawable(progress, Gravity.LEFT,
            ClipDrawable.HORIZONTAL);

    LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] {
            clipDrawable, background });

But I cannot control the ring's diameter or thickness. Any ideia of how can I solve this?

Victor Gomes
  • 128
  • 10
  • Possible duplicate of [How to create circular ProgressBar in android?](http://stackoverflow.com/questions/27213381/how-to-create-circular-progressbar-in-android) – Iharob Al Asimi Feb 09 '17 at 21:54

0 Answers0