Progress bar for Android learning notes)

Source: Internet
Author: User

I. Description

<1> In the process of continuous work, in order to prevent users from feelingProgramThe progress bar of the activity is required, indicating that the process is in progress.

<2> during some operationsA visual indicator that shows you the progress of the operation,It also has a secondary progress bar to display the intermediate progress, such as the progress in the buffer area of streaming media playback.A progress bar cannot be determined.In uncertain mode, the progress bar displays a circular animation.This mode is often used in applications. The length of a task is unknown.

Ii. Important XML attributes

Android: progressbarstyle: Default progress bar style

Android: progressbarstylehorizontal: horizontal style

Iii. Important Methods

Getmax():Returns the maximum range of the progress bar.

Getprogress(): Return the progress

Getsecondaryprogress(): Returns the secondary progress.

Incrementprogressby(INT diff): Specifies the increase progress.

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

Setindeterminate(Boolean indeterminate): sets the uncertain mode.

Setvisibility(Int v): sets whether the progress bar is visible.

4. Important Events

Onsizechanged(Int w, int H, int oldw, int oldh): this event is triggered when the progress value changes.

1. Default progress bar (medium circle)

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "fill_parent" <br/> Android: Orientation = "vertical"> <br/> <textview <br/> Android: id = "@ + ID/Information" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" <br/> Android: TEXT = "(-) default progress bar (medium circle)"/> <br/> <progressbar <br/> Android: id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content"/> <br/> </linearlayout>

2 progressbarstylelarge (large circle)

<Progressbar <br/> Android: Id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylelarge "/>

 

Progressbarstylesmall (small circle)

<Progressbar <br/> Android: Id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylesmall "/>

Progressbarstylesmalltitle Title Bar progress bar

Main. xml:

<Progressbar <br/> Android: Id = "@ + ID/processbar" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylesmalltitle "/>

Java

Package android2.test; </P> <p> Import android. app. activity; <br/> Import android. OS. bundle; <br/> Import android. view. window; </P> <p> public class android2activity extends activity {<br/>/** called when the activity is first created. */<br/> @ override <br/> Public void oncreate (bundle savedinstancestate) {<br/> super. oncreate (savedinstancestate); <br/> requestwindowfeature (window. feature_indeterminate_progress); <br/> setcontentview (R. layout. main); <br/> setprogressbarindeterminatevisibility (true); <br/>}< br/>}

Requestwindowfeature (window. feature_progress );
// Set the feature style of the window progress bar

Setprogressbarindeterminatevisibility (true); // you can specify the progress bar visibility.:

 

5. ssbarstylehorizontal (rectangular progress bar)

<Progressbar <br/> Android: Id = "@ + ID/progressbar" <br/> Android: layout_width = "200dp" <br/> Android: layout_height = "wrap_content" <br/> style = "? Android: ATTR/progressbarstylehorizontal "<br/> Android: max =" 100 "<br/> Android: Progress =" 50 "<br/> Android: secondaryprogress = "70" <br/>

Android: max = "100" maximum progress: 100

Android: Progress = "50" Current initialization progress value: 50

Android: secondaryprogress = "70" Current initialization 2nd Progress value 70

Sat.

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.