"Android Custom Controls" ProgressBar Custom

Source: Internet
Author: User

ProgressBar is divided into vertical and horizontal

Often during the data loading process, in order to make the user feel friendly, pop up a circular loading box



Levels are often used when downloading applications and are accompanied by download progress.



There are four types of ProgressBar styles:

Android:progressbarstyle: Default progress bar style, indeterminate mode

Android:progressbarstylehorizontal: Horizontal progress bar Style

Android:progressbarstylelarge: Large progress bar style, also indeterminate progress mode

Android:progressbarstylesmall: Small progress bar style, also indeterminate progress mode


Change the style of ProgressBar styles to achieve different effects


the first: Custom style simple way only need to modify progressbar properties drawable loaded pictures, you can implement different styles

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "android:orientation=" vertical "android:layout_width=" fill_parent "android:layout_height=" Fill_parent " android:gravity= "center" ><progressbarandroid:indeterminatedrawable= "@drawable/d_stroke" Android:layout_ height= "100DP" android:layout_width= "100DP"/></linearlayout>



<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "android:orientation=" vertical "android:layout_width=" fill_parent "android:layout_height=" Fill_parent " android:gravity= "center" ><progressbarandroid:indeterminatedrawable= "@drawable/d_shape" Android:layout_ height= "100DP" android:layout_width= "100DP"/></linearlayout>



The second is to modify its system properties and property values according to the style of the system itself.

First Look at style = "? Android:attr/progressbarstylelarge" the source code, in \frameworks\base\core\res\res\values\styles.xml

<style name= "Progressbarstylelarge" > <item name= "android:indeterminatedrawable" > @drawable/progress_ large</item> <item name= "android:minwidth" >76dip</item> <item name= "Android:maxwidth" > 76dip</item> <item name= "android:minheight" >76dip</item> <item name= "Android:maxheight" > 76dip</item></style>


The third is the second type of workaround, custom style inherits the system's style

<style name= "Myprogressbarstylelarge" parent= "Progressbarstylelarge" > <item name= "android: Indeterminatedrawable "> @drawable/progress_large</item> <item name=" Android:minwidth ">76dip</ item> <item name= "android:maxwidth" >76dip</item> <item name= "Android:minheight" >76dip</ item> <item name= "Android:maxheight" >76dip</item></style>





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.