Android Studio-4.5 ProgressBar and its subclass, androidprogressbar
I. Preface
ProgressBar itself represents the progress bar component. It also derives two common components: SeekBar and RatingBar. Their usage is similar, but there are some differences in the display interface. Let's take a look at the descriptions in the API documentation:
Xml property name Description Android: animationResolution Animation timeout time, which must be an integer, such as "100" Android: indeterminate This attribute is set to true, indicating that the progress is not displayed accurately. Android: indeterminateBehavior Set how to describe the maximum value when you choose not to accurately display the progress Android: indeterminateDrawable Sets the drawable object to be drawn when the progress is not displayed accurately. Android: indeterminateDuration Set the duration for inaccurate display of progress Android: indeterminateOnly The setting only adopts the inaccurate display progress mode (status holding mode will not work) Android: interpolator Android: max Set the maximum progress Value Android: maxHeight Optional parameter sets the maximum View height Android: maxWidth Optional parameter sets the maximum width of the View Android: minHeight Optional parameter sets the minimum View height Android: minWidth Optional parameter sets the minimum View width Android: appsforrtl Defines whether to reflect the canvas in RTL mode. The default value is false. Android: progress Set the progress value of this progress. Android: progressDrawable Set the drawable object corresponding to the progress bar Android: secondaryProgress Secondary progress bar, mainly used in Cache Usage scenarios
This table is taken from API19 documents.
The progress bar supports multiple styles and can be set directly by setting the style attribute. the following attributes are also provided in the API:
Widget. ProgressBar. Horizontal progress bar
Widget. ProgressBar. Small ring progress bar
Widget. ProgressBar. Large ring progress bar
Widget. ProgressBar. Inverse general-sized ring progress bar
Widget. ProgressBar. Small. Inverse Small ring progress bar
Widget. ProgressBar. Large. Inverse Large ring progress bar
Another method is to use the ATT attribute of the system, for example:
- Style = "? Android: attr/progressBarStyle"
- Style = "? Android: attr/progressBarStyleHorizontal"
- Style = "? Android: attr/progressBarStyleInverse"
- Style = "? Android: attr/progressBarStyleLarge"
- Style = "? Android: attr/progressBarStyleLargeInverse"
- Style = "? Android: attr/progressBarStyleSmall"
- Style = "? Android: attr/progressBarStyleSmallInverse"
- Style = "? Android: attr/progressBarStyleSmallTitle"
For example, the following code:
Attribute Description Android: isIndicator Set whether the star rating allows the user to the table (true is not allowed to change) Android: numStars Set the total number of stars for this star rating bar Android: rating Set the default star rating for this star rating bar Android: stepSize Set the minimum number of stars to be changed each time
Let's give an example to illustrate these attributes:
Let's take a look at the effect first:
Then we will provide the layout file:
Max and progress are properties in the progress bar, because RatingBar itself is a special progress bar, set the maximum value to 0.5, 5 stars to display, that is, a star is 20, step by step, it indicates that at least half a star can be selected at a time.
The background mainly processes the listener for changes.
V. Postscript
There have been a lot of chores recently, and the learning progress has slowed down. If you encounter problems for a long time, you need to take a deeper look at some problems and take a look at the examples and API documentation in the SDK. The following sections skip the use of some simple controls and provide the location of the sample code in the SDK. It is no longer a waste of space on blogs. Accelerate learning.