Creating a semi border of circle with textview - android

I want some thing like this image. The blue color on the border of the circle is custom and should increase/decrease as per the value in text view. I would like to have some ideas to implement it.

Please try with the below code
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="3"
android:thicknessRatio="10" android:useLevel="false">
<size android:width="100dip" android:height="100dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#4ab0da"
android:endColor="#4ab0da"
android:centerColor="#eee"
android:angle="0"
/>
</shape>
</rotate>

Please visit this Circle Progress Indicator official blog
Features
Increase or decrease progress changes
Modifiable
Ring width
Ring background color
Ring fill color
Ring gradient

Related

How to make a ProgressBar move in anti Clockwise android

I have a normal progressBar, but I need the progress to move from right to left instead of left to right.
I've tried using
android:layoutDirection="rtl"
and
android:layoutDirection="ltr"
even tried making a custom drawable for it too, made a progress.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="-270"
android:toDegrees="270"
android:duration = "5000">
<shape
android:shape="ring"
android:innerRadiusRatio="3"
android:thicknessRatio="8"
android:useLevel="false">
<size
android:width="20dp"
android:height="20dp" />
<gradient
android:type="sweep"
android:useLevel="false"
android:startColor="#color/white"
android:endColor="#00ffffff"
android:angle="90"/>
</shape>
</rotate>
still not working
Please I need an idea of how to handle this.
Thank you in advance.
Try flipping your ProgressBar Simply by setting
android:scaleX="-1"
Try adding the following flag to your XML, I don't think you need a custom drawable. This should do the trick. What I mean is to add it your ProgressBar XML
android:rotation="180"
<ProgressBar
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotation="180"
/>

how to get the color code from Gradient in android ProgressBar

I have created the ring shaped curved gradient for the progress bar, to make it curved from the edge i have created the ring shaped dot item in layer-list and set one at the starting of the progress and the other one at the bottom. The issue here is gradient color effect is dynamic so i have to change the bottom dot color to same as gradient bottom color, is there a way to get the gradient bottom color code dynamically ? Attached image is the exact layout i'm trying to implement.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/gradientDrawable">
<rotate
android:fromDegrees="270"
android:toDegrees="270">
<shape
android:innerRadiusRatio="2.67"
android:shape="ring"
android:thickness="#dimen/_6sdp"
android:thicknessRatio="40.0">
<gradient
android:centerColor="#E85E44"
android:endColor="#FF9C00"
android:startColor="#FF9C00"
android:type="sweep" />
</shape>
</rotate>
</item>
<item android:id="#+id/topDot" android:bottom="#dimen/_126sdp">
<shape
android:innerRadiusRatio="5000"
android:shape="ring"
android:thickness="#dimen/_3sdp"
android:useLevel="false">
<solid android:color="#FF9C00" />
</shape>
</item>
<item android:id="#+id/bottomDot">
<rotate>
<inset android:insetBottom="#dimen/_126sdp">
<shape
android:innerRadiusRatio="5000"
android:shape="ring"
android:thickness="#dimen/_3sdp"
android:useLevel="false">
<solid android:color="#E85E44" />
</shape>
</inset>
</rotate>
</item>
</layer-list>

How to make 2 (Double) Ring Custom Progress Bar

Single progress bar is quite old fashioned. I am trying to make a double ring
circular progress bar.
I have been adding two shapes inside the XML code by it gives error.
<?xml version="1.0" encoding="utf-8" ?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="4"
android:thicknessRatio="4" android:useLevel="false">
<size android:width="76dip" android:height="76dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#396338"
android:endColor="#00FF00"
android:angle="0" />
</shape>
</rotate>
Current progress bar:
But I want to make something like this:
why don't you try to use two progressbar where outer progressbar's value can be used by inner progressbar simultaneously

Android drawable behind a bitmap

I am trying to achieve this crazy thing but I not sure if this is possible using Android drawable.
I have an image which as some transparent parts, then I am trying to have another gradient sweep element behind this Image to rotate so that the transparent parts of image get moving gradient color.
As of now, I am able to get Image and an gradient sweep behind it but it is not rotating and effect is not as I expected. Any suggestion/tips/code snippets will be helpful.
Here is my drawable XML.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape
android:innerRadiusRatio="15"
android:shape="ring"
android:thicknessRatio="4"
android:useLevel="false">
<gradient
android:angle="0"
android:endColor="#color/colorAccent"
android:startColor="#android:color/white"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
</item>
<item>
<bitmap
android:gravity="center"
android:src="#drawable/inoffline" />
</item>
</layer-list>
and the output image, I have swapped the transparent parts of image so that i could easily verify that both drawable are rendered.
Regards,
Harsha

Lollipop - ProgressDialog color change

I started porting my app into lollipop. I was able to theme the whole app to a particular color I like but I can't change the color of the ProgressDialog which is always green. Is there any way to do this?
You have to find the asset and change its color with photoshop, or create a new asset and use that as progress dialog.
The new asset can be created like :
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="3"
android:thicknessRatio="8" android:useLevel="false">
<size android:width="76dip" android:height="76dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#447a29"
android:endColor="#447a29"
android:angle="0"
/>
</shape>
and call this progress.xml for example then use it like this :
<ProgressBar
android:id="#+id/ProgressBar01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background ="#xml/progress">
and you have only to change the start and end color to make it how you want it

Categories

Resources