Android 0 Basics Section 51st: progress bar ProgressBar

Source: Internet
Author: User

Unconsciously this is the 51st issue, in the previous 50, we learned some of the very high frequency of Android development UI components, of course, these components are not enough to complete the development of all apps, but also often use some such as progress bar, drag bar, search box, time and date selector and other components, Then learn these advanced components together in later installments.

First, ProgressBar series components

ProgressBar is also an important set of components, and the ProgressBar itself represents the progress bar component, which also derives two commonly used components: Seekbar and Ratingbar. ProgressBar and its subclasses are very similar in usage, except that there are certain differences in the display interface, so this section puts them in a category, focuses on their commonalities, and highlights their differences.

The class diagram for ProgressBar and its subclasses is as follows:

ProgressBar inherits from the view class, and the direct subclasses have Absseekbar and Contentloadingprogressbar, where Absseekbar subclasses have Seekbar and Ratingbar, It can be seen that the two are based on ProgressBar implementation.

Second, the ProgressBar Foundation

The progress bar is also a very useful component in the UI interface, and is typically used to show the user the percentage of a time-consuming operation completed.

The progress bar can dynamically display progress, thus avoiding a lengthy time-consuming operation, allowing the user to feel that the program has lost its response, thereby improving user interface friendliness.

Android supports a variety of style progress bars, which can be specified by the Style property for ProgressBar. This property can support several property values such as:

    • @android: Style/widget.progressbar.horizontal: Horizontal progress bar.

    • @android: style/widget.progressbar.inverse: Normal-sized circular progress bar.

    • @android: Style/widget.progressbar.large: Large loop progress bar.

    • @android: Style/widget.progressbar.large.inverse: Large loop progress bar.

    • @android: Style/widget.progressbar.small: Small loop progress bar.

    • @android: Style/widget.progressbar.small.inverse: Small loop progress bar.

In fact, in Android development, ProgressBar style settings in two ways, in addition to the above, there is a way to use the following:

    • ? android:attr/progressbarstyle

    • ? android:attr/progressbarstylehorizontal

    • ? android:attr/progressbarstyleinverse

    • ? android:attr/progressbarstylelarge

    • ? android:attr/progressbarstylelargeinverse

    • ? android:attr/progressbarstylesmall

    • ? android:attr/progressbarstylesmallinverse

    • ? android:attr/progressbarstylesmalltitle

In addition, ProgressBar supports the following common XML attributes:

    • Android:max: The maximum value of the progress bar.

    • Android:progress: Progress bar has completed progress value.

    • Android:progressdrawable: Sets the Drawable object corresponding to the track.

    • Android:indeterminate: If set to true, the progress bar does not accurately display the progress.

    • Android:indeterminatedrawable: Sets the Drawable object for progress bars that do not display progress.

    • Android:indeterminateduration: Sets the duration for which the progress is not accurately displayed.

    • Android:secondaryprogress: Level Two progress bar, similar to the video playback is the current playback progress, one is the buffering progress.

Where android:progressdrawable is used to specify the drawing form of the track for the progress bar, which can be specified as a reference to a Layerdrawable object.

ProgressBar provides the following methods to manipulate progress:

    • Getmax (): Returns the upper limit of the range of this progress bar.

    • Getprogress (): Returns progress.

    • Getsecondaryprogress (): Returns the secondary progress.

    • Incrementprogressby (int diff): Specifies the incremental progress. Progress is increased when positive, and progress is decreased when negative.

    • Isindeterminate (): Indicates whether the progress bar is in indeterminate mode.

    • Setindeterminate (Boolean indeterminate): Sets whether the mode is indeterminate.

Iii. Examples of ProgressBar

Next, use a simple example program to learn the default ProgressBar of the system.

The Advanced UI Components section, which starts with this issue, uses the new module to create a new Advancedviewsample module with reference to the creation method of the first knowledge ListView.

This sample user interface is very simple, and the code for the new program's layout file Activity_main.xml is as follows:

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" >    <!--the system provides a circular progress bar, which in turn is a large small -    <ProgressBarstyle= "@android: Style/widget.progressbar.small"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" />    <ProgressBarAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" />    <ProgressBarstyle= "@android: Style/widget.progressbar.large"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" />    <!--system-provided horizontal progress bar -    <ProgressBarstyle= "@android: Style/widget.progressbar.horizontal"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:max= "+"android:progress= "+" />    <ProgressBarstyle= "@android: Style/widget.progressbar.horizontal"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:layout_margintop= "10DP"android:indeterminate= "true" /></LinearLayout>

The above interface layout file defines three circular progress bars, which do not show progress, it just shows a constantly rotating picture.

Two horizontal progress bars are defined after the layout file, the first progress bar has a progress value set, and the second progress bar does not accurately display the progress.

The rest of the program without modification, directly run the program can see the interface effect shown.

From the discovery, these progress bars are not very beautiful, and can not show the specific progress value, which requires the developer to customize the ProgressBar, we will come to study together next time.

Come here today, if you have any questions welcome message to discuss together, also welcome to join the Android 0 Basic introductory Technical discussion group, grow together!

This article copyright for the public Share talent show (Shareexpert)--Xin 鱻 all, if necessary reprint please contact the author authorized, hereby declare!

Past period Summary share:

Android 0 Basics Introduction 1th: Android's past life

Android 0 Basics Section 2nd: Android system Architecture and application components those things

Android 0 Basics Section 3rd: Bring you up to talk about Android development environment

Android 0 Basics 4th: Installing and configuring the JDK correctly Ko fu the first trick

Android 0 Basics 5th: Use ADT bundles to easily meet the goddess

Android 0 Basics 6th: Configuration Optimization SDK Manager, official dating goddess

Android 0 Basics 7th: Take care of Android simulator and start the Sweet journey

Android 0 Basics 8th: HelloWorld, the starting point for my first trip

Android 0 Basics 9th: Android app, no code can be developed

Android 0 Basics Section 10th: Development IDE Big upgrade, finally ushered in Android Studio

Android 0 Basics Introductory Section 11th: Simple steps to take you to fly, run Android Studio project

Android 0 Basics 12th: Get familiar with the Android studio interface and start selling

Android 0 Basics 13th: Android Studio Configuration optimization to create a development tool

Android 0 Basics 14th: Using high-speed genymotion, stepping into the rocket era

Android 0 Basics Section 15th: Mastering the Android Studio project structure, sailing

Android 0 Basics Section 16th: Android User Interface Development overview

Android 0 Basics Section 17th: text box TextView

Android 0 Basics Section 18th: Input box EditText

Android 0 Basics Get started section 19th: Buttons button

Android 0 Basics 20th: check box checkbox and radio button radiobutton

Android 0 Basics Section 21st: Switch Components ToggleButton and switch

Android 0 Basics Section 22nd: Image View ImageView

Android 0 Basics Section 23rd: Image button ImageButton and zoom button Zoombutton

Android 0 Basics Section 24th: Customize view simple to use to create your own controls

Android 0 Basics Section 25th: Simple and most commonly used linearlayout linear layouts

Android 0 Basics Section 26th: Two alignments, layout_gravity and gravity differ greatly

Android 0 Basics section 27th: Using padding and margin correctly

Android 0 Basics Section 28th: Easy to master relativelayout relative layout

Android 0 Basics 29th: Use tablelayout table layouts

Android 0 Basics 30th: Two minutes master Framelayout frame layout

Android 0 Basics Section 31st: absolutelayout absolute Layout with less

Android 0 Basics Section 32nd: New GridLayout Grid layout

Android 0 Basics section 33rd: Android Event Handling overview

Android 0 Basics Section 34th: Listening-based event handling in Android

Android 0 Basics Section 35th: Callback-based event handling in Android

Android 0 Basics Section 36th: Handling of Android system events

Android 0 Basics 37th: First Knowledge ListView

Android 0 Basics 38th: First Knowledge Adapter

Android 0 Basics section 39th: listactivity and custom list items

Android 0 Basics Section 40th: Customizing Arrayadapter

Android 0 Basics Section 41st: Using Simpleadapter

Android 0 Basics Section 42nd: Customizing Baseadapter

Android 0 Basics section 43rd: ListView Optimization and List End-to-end use

Android 0 Basics Section 44th: ListView Data Dynamic Update

Android 0 Basic Getting Started section 45th: Grid view GridView

Android 0 Basics section 46th: List Options Box spinner

Android 0 Basic Getting Started section 47th: AutoComplete text Box Autocompletetextview

Android 0 Basics Section 48th: Collapsible list Expandablelistview

Android 0 Basics section 49th: Adapterviewflipper picture Carousel

Android 0 Basics Section 50th: StackView card Stacking

Android 0 Basics Section 51st: progress bar ProgressBar

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.