ProgressBar位于android.view包下面。
在某些正在执行的操作的一些可见的指示,展示一个进度条标示这个操作运行了多长时间,应用可以更改进度条的进度。还可以有另外一个进度提示在progress bar上面,他的颜色会比第一个颜色浅一些。经常用户缓冲区的显示。
progress bar 可以设置成非确定模式,这种模式中进度条显示一个周期性的动画,这种进度条用做任务的长度没办法确定的情况。
|
XML Attributes | ||
|
Attribute Name |
Related Method |
Description |
|
android:progressBarStyle |
|
Default ProgressBar style. |
|
android:progressBarStyleHorizontal |
|
Horizontal ProgressBar style. |
|
android:progressBarStyleLarge |
|
Large ProgressBar style. |
|
android:progressBarStyleSmall |
|
Small ProgressBar style. |
|
Public Constructors |
| ||||||
|
|
ProgressBar(Context context) Create a new progress bar with range 0...100 and initial progress of 0. |
| |||||
|
|
ProgressBar(Context context, AttributeSet attrs) |
| |||||
|
|
ProgressBar(Context context, AttributeSet attrs, int defStyle) |
|
| ||||
|
Public Methods | |||||||
|
Drawable |
getIndeterminateDrawable() 在indeterminate模式中,获得当前正在使用的可绘资源 |
| |||||
|
Interpolator |
getInterpolator() 在indeterminate模式中,动画的加速曲线,和interpolator相关. |
| |||||
|
synchronized int |
getMax() 最大值 |
| |||||
|
synchronized int |
getProgress() 返回当前进度,在indeterminate模式下只返回0 |
| |||||
|
Drawable |
getProgressDrawable() 在progress模式下获取当前绘制的资源 |
| |||||
|
synchronized int |
getSecondaryProgress() secondaryProgress的进度. |
| |||||
|
synchronized final void |
incrementProgressBy(int diff) 增加完成的数量 |
| |||||
|
synchronized final void |
incrementSecondaryProgressBy(int diff) 增加sencondaryProgress数量 |
| |||||
|
void |
invalidateDrawable(Drawable dr) 重绘指定的图标 |
| |||||
|
synchronized boolean |
isIndeterminate() 是否是indeterminate模式 |
| |||||
|
void |
onRestoreInstanceState(Parcelable state) Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState(). |
| |||||
|
Parcelable |
onSaveInstanceState() Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. |
| |||||
|
void |
postInvalidate() 产生一个invaildate,通常用于non-uithread更新ui界面 |
| |||||
|
synchronized void |
setIndeterminate(boolean indeterminate) Change the indeterminate mode for this progress bar. |
| |||||
|
void |
setIndeterminateDrawable(Drawable d) 设置indeterminate模式下的图片资源 |
| |||||
|
void |
setInterpolator(Context context, int resID) 设置indeterminate模式下面的周期 |
| |||||
|
void |
setInterpolator(Interpolator interpolator) 设置indeterminate模式下面的周期 |
| |||||
|
synchronized void |
setMax(int max) progress模式下设置最大值 |
| |||||
|
synchronized void |
setProgress(int progress) 指定进度 |
| |||||
|
void |
setProgressDrawable(Drawable d) 指定progress模式下的资源. |
|
|
| |||
|
synchronized void |
setSecondaryProgress(int secondaryProgress) 设置second progress的进度 |
|
|
| |||
|
void |
setVisibility(int v) progress bar的可见性 |
|
|
| |||
|
Protected Methods | |
|
void |
drawableStateChanged() 当view变化的时候调用该方法,通过这种手段影星drawables |
|
synchronized void |
onDraw(Canvas canvas) 画 |
|
synchronized void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) 在调用onMeasure时候调用该方法 一定要注意:调用setMeasuredDimension(int, int) 存储width 和height,而且还要调用super的onMeasure方法 |
|
void |
onSizeChanged(int w, int h, int oldw, int oldh) 当前的view变化的时候 |
|
boolean |
verifyDrawable(Drawable who) 如果子类有自己的可绘制资源,要重写这个方法,保证这些资源在该方法都返回true |
本文详细介绍了Android中的ProgressBar组件,包括其不同样式、模式及如何通过XML属性进行配置。此外还介绍了ProgressBar的公共方法,如设置进度、最大值等,以及如何在代码中控制其行为。
1053

被折叠的 条评论
为什么被折叠?



