Declare button inside your layout XML file:
<com.dd.CircularProgressButton
android:id="@+id/btnWithText"
android:layout_width="196dp"
android:layout_height="64dp"
android:layout_marginTop="16dp"
android:textColor="@color/white"
android:textSize="18sp"
app:textComplete="@string/Complete"
app:textError="@string/Error"
app:textIdle="@string/Upload" />
Button state depends on progress:
To change progress use CircularProgressButton.setProgress(int value)
method.
Idle state
CircularProgressButton.setProgress(0)
app:textIdle="@string/Upload"
app:colorIdle="@color/green"
Progress state 1
CircularProgressButton.setProgress(1)
will automatically morph
button from idle (square shape) state to progress (circle shape) state.
app:colorIndicator="@color/blue"
app:colorIndicatorBackground="@color/grey"
app:colorProgress="@color/white"
Progress state 50
CircularProgressButton.setProgress(50)
Complete state 100
CircularProgressButton.setProgress(-1)
app:textError="@string/Error"
app:colorError="@color/red"
Error state -1
CircularProgressButton.setProgress(-1)
app:textComplete="@string/Complete"
app:colorComplete="@color/green"
You can set rounded corners
app:cornerRadius="48dp"
You can use icons for complete & error states
app:iconComplete="@drawable/ic_action_accept"
app:iconError="@drawable/ic_action_cancel"
Android 实现环形进度按钮circular-progress-button
原文地址:http://blog.csdn.net/linglongxin24/article/details/38057635