转:http://blog.csdn.net/hongjinqun/article/details/30221201

效果图:

使用 circular-progress-button 实现环形进度按钮

源码地址:https://github.com/dmytrodanylyk/circular-progress-button

使用说明:

 

Usage

 

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:

  • normal state [0]
  • progress state [1-99]
  • success state [100]
  • error state [-1]

To change progress use CircularProgressButton.setProgress(int value) method.

Idle state

CircularProgressButton.setProgress(0)

  • To change text app:textIdle="@string/Upload"
  • To change background color app:colorIdle="@color/green"

 使用 circular-progress-button 实现环形进度按钮

Progress state 1

CircularProgressButton.setProgress(1) will automatically morph button from idle (square shape) state to progress (circle shape) state.

To change indicator color app:colorIndicator="@color/blue"

To change indicator background color app:colorIndicatorBackground="@color/grey"

To change circle background color app:colorProgress="@color/white"

使用 circular-progress-button 实现环形进度按钮

Progress state 50

CircularProgressButton.setProgress(50)

使用 circular-progress-button 实现环形进度按钮

Complete state 100

CircularProgressButton.setProgress(-1)

  • To change text app:textError="@string/Error"
  • To change background color app:colorError="@color/red"

使用 circular-progress-button 实现环形进度按钮

Error state -1

CircularProgressButton.setProgress(-1)

  • To change text app:textComplete="@string/Complete"
  • To change background color app:colorComplete="@color/green"

使用 circular-progress-button 实现环形进度按钮

You can set rounded corners

app:cornerRadius="48dp"

使用 circular-progress-button 实现环形进度按钮

You can use icons for complete & error states

app:iconComplete="@drawable/ic_action_accept"

使用 circular-progress-button 实现环形进度按钮

app:iconError="@drawable/ic_action_cancel"

使用 circular-progress-button 实现环形进度按钮

相关文章:

  • 2021-11-22
  • 2022-01-20
  • 2021-11-28
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2021-10-25
猜你喜欢
  • 2022-12-23
  • 2021-11-13
  • 2021-04-17
  • 2022-02-27
  • 2022-02-15
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案