The style of the Android progress bar
Example 1: (Default style (medium circle))
XML code
<progressbar
Android:id= "@+id/progressbar1"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
/>
Example 2: (Extra large round)
XML code
<progressbar
Android:id= "@+id/progressbar2"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Style= "? Android:attr/progressbarstylelarge"
/>
Example 3: (Small round)
XML code
<progressbar
Android:id= "@+id/progressbar3"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Style= "? Android:attr/progressbarstylesmall"
/>
Example 4: (Title small round)
XML code
<progressbar
Android:id= "@+id/progressbar4"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Style= "? Android:attr/progressbarstylesmalltitle"
/>
Example 4-Use a small circular code in the title:
Java code
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Set title uncertainty progress bar Style
Requestwindowfeature (window.feature_indeterminate_progress);
Setcontentview (R.layout.progress_bars);
Show title Uncertainty progress bar
Setprogressbarindeterminatevisibility (TRUE);
Turn off the title Uncertainty progress bar
Setprogressbarindeterminatevisibility (FALSE);
}
Example 5: (Rectangular progress bar)
XML code
<progressbar
Android:id= "@+id/progressbar5"
Android:layout_width= "200DP"
android:layout_height= "Wrap_content"
Style= "? Android:attr/progressbarstylehorizontal"
android:max= "100"
Android:progress= "50"
Android:secondaryprogress= "70"
/>
android:max= "100" Maximum progress value 100
android:progress= "50" current initialization progress value of 50
Android:secondaryprogress= "70" is currently initializing the 2nd progress value of 70
Example 5-code that uses a rectangular progress bar in the header:
Java code
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Set the title progress bar style
Requestwindowfeature (window.feature_progress);
Setcontentview (R.layout.progress_bars);
Show title Progress
Setprogressbarvisibility (TRUE);
Set title current progress value is 5000 (title progress Max defaults to 10000)
Setprogress (5000);
Turn off title progress
Setprogressbarvisibility (FALSE);
}
Example 6: (Progress dialog box-Circular progress bar)
Java code
ProgressDialog dialog = new ProgressDialog (this);
//Set progress bar style, style is round, rotate
Dialog.setprogressstyle (Progressdialog.style_spinner);
//Set ProgressDialog title
Dialog.setTitle ( "Progress Dialog");
//Set ProgressDialog prompt information
Dialog.setmessage ("Circular progress bar");
//Set ProgressDialog title icon
Dialog.seticon (Android. R.DRAWABLE.IC_DIALOG_MAP);
//Set a button for ProgressDialog;
Dialog.setbutton ("OK", new Progressdialog.onclicklistener () {
@Override
public void OnClick (dialoginterface dialog, int which) {
}
});
//Set ProgressDialog the progress bar is ambiguous
Dialog.setindeterminate (false);
//sets whether ProgressDialog can press the return button to cancel
Dialog.setcancelable (true);
//show
Dialog.show ();
Example 7: (Progress dialog box-Rectangular progress bar)
Java code
ProgressDialog dialog = new ProgressDialog (this);
//Set progress bar style, style is round, rotate
Dialog.setprogressstyle (progressdialog.style_horizontal);
//Set ProgressDialog title
Dialog.settitle ("Progress Dialog");
//Set ProgressDialog prompt information
Dialog.setmessage ("Rectangular progress bar");
// Set ProgressDialog title icon
Dialog.seticon (Android. R.drawable.ic_dialog_alert);
//Set ProgressDialog maximum progress
Dialog.setmax;
// Set a button for ProgressDialog;
Dialog.setbutton ("OK", new Progressdialog.onclicklistener () {
@Override
public void OnClick (Dialoginterface dialog, int which) {
& nbsp;
}
});
// Sets whether ProgressDialog can press the bounce button to cancel
Dialog.setcancelable (true);
//Display
Dialog.show ();
//Set ProgressDialog current progress
dialog.setprogress;