




已阅读5页,还剩22页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ProgressBar进度条extends Viewjava.lang.Object android.view.View android.widget.ProgressBarKnown Direct SubclassesAbsSeekBar, ContentLoadingProgressBarKnown Indirect SubclassesAppCompatRatingBar, RatingBar, SeekBarClass OverviewVisual indicator of progress in some operation. Displays a bar to the user representing how far the operation has progressed; the application can change the amount of progress (modifying the length of the bar) as it moves forward. There is also a secondary progress displayable on a progress bar which is useful for displaying intermediate progress, such as the buffer level during a streaming playback progress bar.A progress bar can also be made indeterminate. In indeterminate mode, the progress bar shows a cyclic animation without an indication of progress. This mode is used by applications when the length of the task is unknown. The indeterminate progress bar can be either a spinning wheel or a horizontal bar.The following code example shows how a progress bar can be used from a worker thread to update the user interface to notify the user of progress: public class MyActivity extends Activity private static final int PROGRESS = 0x1; private ProgressBar mProgress; private int mProgressStatus = 0; private Handler mHandler = new Handler(); protected void onCreate(Bundle icicle) super.onCreate(icicle); setContentView(R.gressbar_activity); mProgress = (ProgressBar) findViewById(R.gress_bar); / Start lengthy operation in a background thread new Thread(new Runnable() public void run() while (mProgressStatus 100) mProgressStatus = doWork(); / Update the progress bar mHandler.post(new Runnable() public void run() mProgress.setProgress(mProgressStatus); ); ).start(); To add a progress bar to a layout file, you can use the element. By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a horizontal progress bar, apply the Widget.ProgressBar.Horizontal style, like so: If you will use the progress bar to show real progress, you must use the horizontal bar. You can then increment the progress with incrementProgressBy() or setProgress(). By default, the progress bar is full when it reaches 100. If necessary, you can adjust the maximum value (the value for a full bar) using the android:max attribute. Other attributes available are listed below.Another common style to apply to the progress bar is Widget.ProgressBar.Small, which shows a smaller version of the spinning wheeluseful when waiting for content to load. For example, you can insert this kind of progress bar into your default layout for a view that will be populated by some content fetched from the Internetthe spinning wheel appears immediately and when your application receives the content, it replaces the progress bar with the loaded content. For example: Other progress bar styles provided by the system include:Widget.ProgressBar.HorizontalWidget.ProgressBar.SmallWidget.ProgressBar.LargeWidget.ProgressBar.InverseWidget.ProgressBar.Small.InverseWidget.ProgressBar.Large.InverseThe inverse styles provide an inverse color scheme for the spinner, which may be necessary if your application uses a light colored theme (a white background).XML attributesSee ProgressBar Attributes, View AttributesSummaryXML AttributesAttribute NameRelated MethodDescriptionandroid:animationResolutionTimeout between frames of animation in millisecondsMust be an integer value, such as 100. android:indeterminateAllows to enable the indeterminate mode. android:indeterminateBehaviorDefines how the indeterminate mode should behave when the progress reaches max. android:indeterminateDrawableDrawable used for the indeterminate mode. android:indeterminateDurationDuration of the indeterminate animation. android:indeterminateOnlyRestricts to ONLY indeterminate mode (state-keeping progress mode will not work). android:indeterminateTintsetIndeterminateTintList(ColorStateList)Tint to apply to the indeterminate progress indicator. android:indeterminateTintModesetIndeterminateTintMode(PorterDuff.Mode)Blending mode used to apply the indeterminate progress indicator tint. android:interpolator android:maxDefines the maximum value the progress can take. android:maxHeightAn optional argument to supply a maximum height for this view. android:maxWidthAn optional argument to supply a maximum width for this view. android:minHeight android:minWidth android:mirrorForRtlDefines if the associated drawables need to be mirrored when in RTL mode. android:progressDefines the default progress value, between 0 and max. android:progressBackgroundTintsetProgressBackgroundTintList(ColorStateList)Tint to apply to the progress indicator background. android:progressBackgroundTintModesetProgressBackgroundTintMode(PorterDuff.Mode)Blending mode used to apply the progress indicator background tint. android:progressDrawableDrawable used for the progress mode. android:progressTintsetProgressTintList(ColorStateList)Tint to apply to the progress indicator. android:progressTintModesetProgressTintMode(PorterDuff.Mode)Blending mode used to apply the progress indicator tint. android:secondaryProgressDefines the secondary progress value, between 0 and max. android:secondaryProgressTintsetSecondaryProgressTintList(ColorStateList)Tint to apply to the secondary progress indicator. android:secondaryProgressTintModesetSecondaryProgressTintMode(PorterDuff.Mode)Blending mode used to apply the secondary progress indicator tint. ExpandInherited XML AttributesFrom class android.view.ViewExpandInherited ConstantsFrom class android.view.ViewExpandInherited FieldsFrom class android.view.ViewPublic ConstructorsProgressBar(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 defStyleAttr)ProgressBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)Public MethodsvoiddrawableHotspotChanged(float x, float y)This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.CharSequencegetAccessibilityClassName()Return the class name of this object to be used for accessibility purposes.DrawablegetIndeterminateDrawable()Get the drawable used to draw the progress bar in indeterminate mode.ColorStateListgetIndeterminateTintList()PorterDuff.ModegetIndeterminateTintMode()Returns the blending mode used to apply the tint to the indeterminate drawable, if specified.InterpolatorgetInterpolator()Gets the acceleration curve type for the indeterminate animation.synchronized intgetMax()Return the upper limit of this progress bars range.synchronized intgetProgress()Get the progress bars current level of progress.ColorStateListgetProgressBackgroundTintList()Returns the tint applied to the progress background, if specified.PorterDuff.ModegetProgressBackgroundTintMode()DrawablegetProgressDrawable()Get the drawable used to draw the progress bar in progress mode.ColorStateListgetProgressTintList()Returns the tint applied to the progress drawable, if specified.PorterDuff.ModegetProgressTintMode()Returns the blending mode used to apply the tint to the progress drawable, if specified.synchronized intgetSecondaryProgress()Get the progress bars current level of secondary progress.ColorStateListgetSecondaryProgressTintList()Returns the tint applied to the secondary progress drawable, if specified.PorterDuff.ModegetSecondaryProgressTintMode()Returns the blending mode used to apply the tint to the secondary progress drawable, if specified.synchronized final voidincrementProgressBy(int diff)Increase the progress bars progress by the specified amount.synchronized final voidincrementSecondaryProgressBy(int diff)Increase the progress bars secondary progress by the specified amount.voidinvalidateDrawable(Drawable dr)Invalidates the specified Drawable.synchronized booleanisIndeterminate()Indicate whether this progress bar is in indeterminate mode.voidjumpDrawablesToCurrentState()Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.voidonRestoreInstanceState(Parcelable state)Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState().ParcelableonSaveInstanceState()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.voidpostInvalidate()Cause an invalidate to happen on a subsequent cycle through the event loop.synchronized voidsetIndeterminate(boolean indeterminate)Change the indeterminate mode for this progress bar.voidsetIndeterminateDrawable(Drawable d)Define the drawable used to draw the progress bar in indeterminate mode.voidsetIndeterminateDrawableTiled(Drawable d)Define the tileable drawable used to draw the progress bar in indeterminate mode.voidsetIndeterminateTintList(ColorStateList tint)Applies a tint to the indeterminate drawable.voidsetIndeterminateTintMode(PorterDuff.Mode tintMode)Specifies the blending mode used to apply the tint specified by setIndeterminateTintList(ColorStateList) to the indeterminate drawable.voidsetInterpolator(Context context, int resID)Sets the acceleration curve for the indeterminate animation.voidsetInterpolator(Interpolator interpolator)Sets the acceleration curve for the indeterminate animation.synchronized voidsetMax(int max)Set the range of the progress bar to 0.synchronized voidsetProgress(int progress)Set the current progress to the specified value.voidsetProgressBackgroundTintList(ColorStateList tint)Applies a tint to the progress background, if one exists.voidsetProgressBackgroundTintMode(PorterDuff.Mode tintMode)Specifies the blending mode used to apply the tint specified by setProgressBackgroundTintList(ColorStateList) to the progress background.voidsetProgressDrawable(Drawable d)Define the drawable used to draw the progress bar in progress mode.voidsetProgressDrawableTiled(Drawable d)Define the tileable drawable used to draw the progress bar in progress mode.voidsetProgressTintList(ColorStateList tint)Applies a tint to the progress indicator, if one exists, or to the entire progress drawable otherwise.voidsetProgressTintMode(PorterDuff.Mode tintMode)Specifies the blending mode used to apply the tint specified by setProgressTintList(ColorStateList) to the progress indicator.synchronized voidsetSecondaryProgress(int secondaryProgress)Set the current secondary progress to the specified value.voidsetSecondaryProgressTintList(ColorStateList tint)Applies a tint to the secondary progress indicator, if one exists.voidsetSecondaryProgressTintMode(PorterDuff.Mode tintMode)Specifies the blending mode used to apply the tint specified by setSecondaryProgressTintList(ColorStateList) to the secondary progress indicator.voidsetVisibility(int v)Set the enabled state of this view.Protected MethodsvoiddrawableStateChanged()This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.voidonAttachedToWindow()This is called when the view is attached to a window.voidonDetachedFromWindow()This is called when the view is detached from a window.synchronized voidonDraw(Canvas canvas)Implement this to do your drawing.synchronized voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)Measure the view and its content to determine the measured width and the measured height.voidonSizeChanged(int w, int h, int oldw, int oldh)This is called during layout when the size of this view has changed.voidonVisibilityChanged(View changedView, int visibility)Called when the visibility of the view or an ancestor of the view has changed.booleanverifyDrawable(Drawable who)If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.ExpandInherited Methods From class android.view.View From class java.lang.Object From interface android.graphics.drawable.Drawable.Callback From interface android.view.KeyEvent.Callback From interface android.view.accessibility.AccessibilityEventSourceXML Attributesandroid:animationResolutionTimeout between frames of animation in millisecondsMust be an integer value, such as 100.This may also be a reference to a resource (in the form package:type:name) or theme attribute (in the form ?package:type:name) containing a value of this type.This corresponds to the global attribute resource symbol animationResolution.Related Methodsandroid:indeterminateAllows to enable the indeterminate mode. In this mode the progress bar plays an infinite looping animation.Must be a boolean value, either true or false.This may also be a reference to a resource (in the form package:type:name) or theme attribute (in the form ?package:type:name) containing a value of this type.This corresponds to the global attribute resource symbol indeterminate.Related Methodsandroid:indeterminateBehaviorDefines how the indeterminate mode should behave when the progress reaches max.Must be one of the following constant values.ConstantValueDescriptionrepeat1Progress starts over from 0.cycle2Progress keeps the current value and goes back to 0.This corresponds to the global attribute resource symbol indeterminateBehavior.Related Methodsandroid:indeterminateDrawableDrawable used for the indeterminate mode.Must be a reference to another resource, in the form +package:type:name or to a theme attribute in the form ?package:type:name.This corresponds to the global attribute resource symbol indeterminateDrawable.Related Methodsandroid:indeterminateDurationDuration of the indeterminate animation.Must be an integer value, such as 100.This may also be a reference to a resource (in the form package:type:name) or theme attribute (in the form ?package:type:name) containing a value of this type.This corresponds to the global attribute resource symbol indeterminateDuration.Related Methodsandroid:indeterminateOnlyRestricts to ONLY indeterminate mode (state-keeping progress mode will not work).Must be a boolean value, either true or false.This may also be a reference to a resource (in the form package:type:name) or theme attribute (in the form ?package:type:name) containing a value of this type.This corresponds to the global attribute resource symbol indeterminateOnly.Related Methodsandroid:indeterminateTintTint to apply to the indeterminate progress indicator.Must be a color value, in the form of #rgb, #argb, #rrggbb, or #aarrggbb.This may also be a reference to a resource (in the form package:type:name) or theme attribute (in the form ?package:type:name) containing a value of this type.This corresponds to the global attribute resource symbol indeterminateTint.Related MethodssetIndeterminateTintList(ColorStateList)android:indeterminateTintModeBlending mode used to apply the indeterminate progress indicator tint.Must be one of the following constant values.ConstantValueDescriptionsrc_over3The tint is drawn on top of the drawable. Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dcsrc_in5The tint is masked by the alpha channel of the drawable. The drawables color channels are thrown out. Sa * Da, Sc * Dasrc_atop9The tint is drawn above the drawable, but with the drawables alpha channel masking the result. Da, Sc * Da + (1 - Sa) * Dcmultiply14Multiplies the color and alpha channels of the drawable with those of the tint. Sa * Da, Sc * Dcscreen15Sa + Da - Sa * Da, Sc + Dc - Sc * Dcadd16Combines the tint and drawable color and alpha channels, clamping the result to valid color values. Saturate(S + D)This corresponds to the global attribute resource symbol indeterminateTintMode.Related MethodssetIndeterminateTintMode(PorterDuff.Mode)android:interpolatorRelated Methodsandroid:maxDefines the maximum value the progress can take.Must be an integer value, such as 100.This may also be a reference to a resource (in the form package:type:name) or theme attribute (in the form ?package:type:name) containing a value of this type.This corresponds to the global attribute resource symbol max.Related Methodsandroid:maxHeightAn optional argument to supply a maximum height for this view. See see android.widget.ImageView#setMaxHeight for details.Must be a dimension value,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年文化遗产数字化保护与利用的数字文化遗产保护技术政策创新实施效果分析
- 宁夏党建面试题库及答案
- 2025年教师招聘之《幼儿教师招聘》测试卷附有答案详解附参考答案详解【研优卷】
- 教师招聘之《小学教师招聘》综合检测题型汇编(巩固)附答案详解
- 2025年教师招聘之《小学教师招聘》通关提分题库含答案详解(预热题)
- 教师招聘之《幼儿教师招聘》能力检测试卷附参考答案详解【培优b卷】
- 教师招聘之《小学教师招聘》考前冲刺分析含答案详解(黄金题型)
- 教师招聘之《小学教师招聘》能力提升B卷题库含答案详解【基础题】
- 子宫肌瘤术后体位真题试题(含答案)
- 道路运输执法规范流程
- 2025-2026学年地质版(2024)小学体育与健康二年级全一册《别让眼睛受伤害》教学设计
- 培训机构紧急封控应急预案
- 工地看场自身安全协议书
- 小学二年级体育教案全集全册1
- 2025秋八年级上册道德与法治新教材全册知识点提纲
- 车辆安全培训课件
- 装修电工施工方案(3篇)
- esg考试试卷问题及答案
- 村医依法执业培训课件
- 外科面试题目及答案
- 翻越您的浪浪山新学期开学第一课+课件
评论
0/150
提交评论