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 text
app:textIdle="@string/Upload"
- To change background color
app: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 color
app:colorIndicator="@color/blue"
- To change indicator background color
app:colorIndicatorBackground="@color/grey"
- To change circle background color
app:colorProgress="@color/white"
Progress state 50
CircularProgressButton.setProgress(50)
Complete state 100
CircularProgressButton.setProgress(-1)
- To change text
app:textError="@string/Error"
- To change background color
app:colorError="@color/red"
Error state-1
CircularProgressButton.setProgress(-1)
- To change text
app:textComplete="@string/Complete"
- To change background color
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"
※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.