Android-implemented loop progress buttons circular-progress-button and androidprogress

Source: Internet
Author: User

Android-implemented loop progress buttons circular-progress-button and androidprogress
※Effect

※The progress button is used for data submission, system logon, and other operations. The animation effect is great and the user experience is improved.
※Usage instructions

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 useCircularProgressButton.setProgress(int value)Method.

Idle state

CircularProgressButton.setProgress(0)

  • To change textapp:textIdle="@string/Upload"
  • To change background colorapp:colorIdle="@color/green"

Progress state 1

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

  • To change indicator colorapp:colorIndicator="@color/blue"
  • To change indicator background colorapp:colorIndicatorBackground="@color/grey"
  • To change circle background colorapp:colorProgress="@color/white"

Progress state 50

CircularProgressButton.setProgress(50)

Complete state 100

CircularProgressButton.setProgress(-1)

  • To change textapp:textError="@string/Error"
  • To change background colorapp:colorError="@color/red"

Error state-1

CircularProgressButton.setProgress(-1)

  • To change textapp:textComplete="@string/Complete"
  • To change background colorapp: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"


※Code 1. Several buttons
  • Initial status [0]
  • Loading [1-99]
  • Loaded successfully [100]
  • Loading failed [-1]
Call this method to change CircularProgressButton. setProgress (int value)

2. Modify the progress bar style
  • Modify the color of the loading progress app: colorIndicator = "@ color/blue"
  • Modify the background color of the loading progress app: colorIndicatorBackground = "@ color/gray"
  • App: colorProgress = "@ color/white"
3. Other attributes

  • Text app in case of failure: textError = "@ string/Error"
  • App: colorError = "@ color/red"
  • Text app: textComplete = "@ string/Complete"
  • Background color app: colorComplete = "@ color/green"
  • Set button rounded corner app: cornerRadius = "48dp"
  • App: iconComplete = "@ drawable/ic_action_accept"
  • App: iconError = "@ drawable/ic_action_cancel"
※Note: When you place more than one button in one row, the position may change because the width of the chart changes when the button is clicked to the Progress box, pay attention to your layout. You can put it in a linear layout separated by proportions, or define the width in the relative layout to keep it centered.



※Common errors
Http://blog.csdn.net/linglongxin24/article/details/38057501

※Project address https://github.com/dmytrodanylyk/circular-progress-button

※Demo
Http://download.csdn.net/detail/u010785585/7666287

※The author's blog
Http://blog.csdn.net/linglongxin24 (it will be updated earlier here, and it will regularly update some of the usual development skills)
In android, how does one click a button in the Custom listview to load a corresponding progress bar?

ExList is the listview, and each item has a progressBar;
Progress is the progress;

View v = exList. getChildAt (I );
ProgressBar bar = (ProgressBar) v. findViewById (R. id. manager_loading_progress_bar );
If (bar! = Null)
Bar. setProgress (progress );
 
In android, there is a ProgressBar progress bar component and a button in mainxml. How can this progress bar be hidden in the initial state?

In mian. xml, set the visibility of ProgressBar to invisible. In the java file, find the ProgressBar ID through findViewById (), assume it is "progressBar", and finally write progressBar In the listener function of the button. setVisibility (View. VISIBLE); that's it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.