问题
How to create CircularProgressBar like below where you can stop the progressbar by taping on cross image.
回答1:
You can use this library CircleProgress . It is easy to use. Here is stages:
Add this gradle file
compile 'com.github.lzyzsd:circleprogress:1.1.0@aar'
Here is xml file
<com.github.lzyzsd.circleprogress.DonutProgress
android:layout_marginLeft="50dp"
android:id="@+id/donut_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
custom:donut_progress="30"/>
For more information visit here
回答2:
create a progressbar tag in your layout :
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="100dp"
android:layout_height="100dp"
android:max="100"
android:progress="0"
android:progressDrawable="@drawable/circular" />
and create a circular.xml drawable :
<shape
android:innerRadiusRatio="2"
android:shape="ring"
android:thickness="2sp" >
<solid android:color="@color/colorPrimary" />
</shape>
for API >= 21 add android:useLevel="true"
to the shape tag in circular.xml.
then in your Activity you would just have to set the progressBar progress depending on current progress and for the cancel button you can just add a button to cancel where you like.
来源:https://stackoverflow.com/questions/37238185/how-to-create-a-circularprogressbar-like-whatsapp-during-image-uploading