Android development progress bar example code

explain

ProgressBar is generally used to display a process, such as data loading process, file download progress, music playback progress, etc.

The default form is ProgressBar

By default, the progressbar is displayed as a circular progress, circling, without displaying the specific progress value. You can control its display and hiding, as shown below

Applicable to interface loading

Horizontal ProgressBar

Horizontal progress bar with progress. Set the style of ProgressBar to style = "? Android: attr / progressbarstylehorizontal"

The max attribute specifies the total progress value of the progress bar, and progress sets the current progress value, or the initial progress value

Setting progress bar background

The color of the system's own progress bar is monotonous, which is less used in actual development. You can customize the progress bar background and create a new progress bar_ Bg.xml file

Gradient can set the gradient color of the progress bar, and Android: endcolor and Android: startcolor can set the color of the beginning and end of the gradient. Once defined, you can use

Effect picture, here is set with yellow rectangular background and yellow progress bar

Dynamic settings

When downloading music from the network, you need to dynamically load the progress bar. By default, set the progress bar and use setprogress(). But sometimes, in addition to dynamically setting the progress, you still need to dynamically set the progress bar color

Music playing example

Play music and get progress through mediaplayer, and set progress

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>