How to create a CircularProgressBar like whatsApp during image uploading? [duplicate]

我是研究僧i 提交于 2019-12-13 08:28:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!