Android Study Notes (24): progress bar component and its subclass

Source: Internet
Author: User

Android Study Notes (24): progress bar component and its subclass

ProgressBar is used as the progress bar component. It also derives SeekBar (drag bar) and RatingBar (star rating bar ).

XML attributes supported by ProgressBar:

Attribute Name

Related Method

Description

Style

 

Set ProgressBar to specify the style

Android: indeterminate

 

When it is set to true, the progress bar does not display progress

Android: indeterminateBehavior

 

In indeterminate mode, the animation processing behavior when the progress bar reaches the maximum value:

"Repeat" | Animation. RESTART, where the Animation starts from the beginning.

"Cycle" | Animation. REVERSE. The Animation is executed from the beginning.

Android: indeterminateDrawable

 

The Drawable object used in indeterminate mode. If the object is an animation object (inherited from Animatable), the animation will be started in the onDraw method.

Android: indeterminateDuration

 

Duration of the progress bar in indeterminate Mode

Android: indeterminateOnly

 

Force indeterminate Mode

Android: max

 

Set the maximum value of this progress bar

Android: maxHeight

 

Set the ProgressBar Specification

Android: maxWidth

 

Android: minHeight

 

Android: minWidth

 

Android: progress

 

Set the progress value of this progress bar.

Android: progressDrawable

 

Set the Drawable object of the progress bar

Attribute values supported by style:

@ Android: style/Widget. ProgressBar. Horizontal: Horizontal progress bar

@ Android: style/Widget. ProgressBar. Inverse: general-sized ring progress bar

@ Android: style/Widget. ProgressBar. Large: Large ring progress bar

@ Android: style/Widget. ProgressBar. Large. Inverse: Large ring progress bar

@ Android: style/Widget. ProgressBar. Small: Small Ring progress bar

@ Android: style/Widget. ProgressBar. Small. Inverse: Small Ring progress bar

The progressDrawable attribute can be set to a LayerDrawable object, indicating that the progress of completion and the progress of unfinished display are different images. LayerDrawable objects can be used in XML files. Element configuration.

You can perform the following operations on the progress:

SetProgress (int): Set the percentage of progress completed.

IncrementProgressBy (int): sets the progress to increase or decrease (plus or minus)

In addition, there is a progress bar directly displayed on the window title in Android, which is directly enabled by the Activity method:

RequestWindowFeature () is used to set the progress bar that does not display progress when the input parameter Window. FEATURE_INDETERMINATE_PROGRESS is set. The input parameter Window. FEATURE_PROGRESS is used to set the progress bar. SetProgressBarIndeterminateVisibility (boolean) and setProgressBarVisibility (boolean) set the display and hide of the progress bar.

Drag a SeekBar

The corresponding value can be obtained through the slider position.

Android: thumb: Specifies the Drawable object of the slider.

To monitor the variation of the slider position, you need to bind an OnSeekBarChangeListener listener to it.

RatingBar

Progress is represented by the star level.

XML attributes supported by RatingBar:

Attribute Name

Related Method

Description

Android: isIndicator

 

Set whether the star rating bar can be changed

Android: numStars

 

Set the total number of stars in a star rating bar

Android: rating

 

Set the default star rating

Android: stepSize

 

Set the minimum number of stars to be changed each time

To monitor changes in the star rating bar, you need to bind an OnRatingBarChangeListener listener to it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.