Reputation: 542
I want to draw circular progress with animation around imageview.Depending on % percentage value as input. For example,If I give 70% it should draw 70%(252 degree) circle around imageview. Any help appreciated.
Upvotes: 1
Views: 1241
Reputation: 31
There is a widget available from here: https://android-arsenal.com/details/1/1446 which will give you the functionality for making a Circular Progress View which draws the arc-angle based on your progress. There is a step-by-step guide for including it in your project.
To get the ImageView in the center of your progrss circle, you can simply use a RelativeLayout to place it exactly where you need. In this example, I placed the ImageView in the center of the screen. Here is the layout xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.robert.androidmodule.MainActivity">
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:indeterminate="false"
android:max="100"
android:progress="100"
android:progressDrawable="@drawable/circle_progress_background" />
<ProgressBar
android:id="@+id/circle_progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:indeterminate="false"
android:max="100"
android:progressDrawable="@drawable/circle_progress_foreground"
android:rotation="-90" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
app:srcCompat="@mipmap/ic_launcher" />
</RelativeLayout>
In this example, I used the basic android icon.
Here is a picture of it working.
Hope this helps!
Upvotes: 0
Reputation: 2275
https://android-arsenal.com/details/1/1446 It would help to create circle progress indicator. You can find the Github link from above.
Upvotes: 0
Reputation: 4888
I faced the same situation once, try to use this Circular Progress View https://github.com/rahatarmanahmed/CircularProgressView , you can set the percentage each time the upload is progressing.
Upvotes: 1