Android progress bar style
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: (ultra-Circular)
XML Code
<Progressbar
Android: Id = "@ + ID/progressbar2"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Style = "? Android: ATTR/progressbarstylelarge"
/>
Example 3: (small circle)
XML Code
<Progressbar
Android: Id = "@ + ID/progressbar3"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Style = "? Android: ATTR/progressbarstylesmall"
/>
Example 4: (Title: Circular)
XML Code
<Progressbar
Android: Id = "@ + ID/progressbar4"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Style = "? Android: ATTR/progressbarstylesmalltitle"
/>
Example 4-code for using a small circle in the title:
Java code
@ Override
Public void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
// Set the title uncertainty progress bar style
Requestwindowfeature (window. feature_indeterminate_progress );
Setcontentview (R. layout. progress_bars );
// Display the title uncertainty progress bar
Setprogressbarindeterminatevisibility (true );
// Close 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: 100
Android: Progress = "50" Current initialization progress value: 50
Android: secondaryprogress = "70" Current initialization 2nd Progress value 70
Example 5-code for using a rectangular progress bar in the title:
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 );
// Display the title progress
Setprogressbarvisibility (true );
// Set the title progress to 5000 (the maximum title progress value is 10000 by default)
Setprogress (5000 );
// Close the title progress
// Setprogressbarvisibility (false );
}
Example 6: (Progress dialog box-circular progress bar)
Java code
Progressdialog dialog = new progressdialog (this );
// Set the progress bar style, circle style, and Rotation
Dialog. setprogressstyle (progressdialog. style_spinner );
// Set the progressdialog title
Dialog. settitle ("Progress dialog box ");
// Set progressdialog prompt information
Dialog. setmessage ("circular progress bar ");
// Set the 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 whether the progress bar of progressdialog is clear
Dialog. setindeterminate (false );
// Sets whether progressdialog can be canceled by pressing the return button.
Dialog. setcancelable (true );
// Display
Dialog. Show ();
Example 7: (Progress dialog box-rectangular progress bar)
Java code
Progressdialog dialog = new progressdialog (this );
// Set the progress bar style, circle style, and Rotation
Dialog. setprogressstyle (progressdialog. style_horizontal );
// Set the progressdialog title
Dialog. settitle ("Progress dialog box ");
// Set progressdialog prompt information
Dialog. setmessage ("rectangular progress bar ");
// Set the progressdialog title icon
Dialog. seticon (Android. R. drawable. ic_dialog_alert );
// Set the maximum progress of progressdialog
Dialog. setmax (100 );
// Set a button for progressdialog
Dialog. setbutton ("OK", new progressdialog. onclicklistener (){
@ Override
Public void onclick (dialoginterface dialog, int which ){
}
});
// Sets whether progressdialog can be canceled by pressing the return button.
Dialog. setcancelable (true );
// Display
Dialog. Show ();
// Set the current progress of progressdialog
Dialog. setprogress (50 );