ProgressBar Styles in Android

Source: Internet
Author: User


Android system has been changed by major manufacturers, all kinds of system components in different mobile phone display effect is completely different, now want to maintain a unified interface style in development, must all modify the system component style, now we need to modify the system default ProgressBar , In the case of Android itself, different versions of the components will have different styles.

ProgressBar styles in the system


Locate the android-sdk directory under platforms\android-15\data\res\values styles.xml , and then find the ProgressBar that you can find

<stylename="Widget.progressbar"> <Item name="Android:indeterminateonly">true</Item> <Item name="Android:indeterminatedrawable"> @android:d rawable/progress_medium_white</Item> <Item name="Android:indeterminatebehavior">Repeat</Item> <Item name="Android:indeterminateduration">3500</Item> <Item name="Android:minwidth"> -dip</Item> <Item name="Android:maxwidth"> -dip</Item> <Item name="Android:minheight"> -dip</Item> <Item name="Android:maxheight"> -dip</Item> </style>

android:indeterminateDrawableThe value is @android:drawable/progress_medium_white , locate the Progress_medium_white.xml in the drawable directory, open

<?xml version="1.0" encoding="utf-8"?><animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"    android:drawable="@drawable/spinner_white_48"    android:pivotX="50%"    android:pivotY="50%"    android:framesCount="12"    android:frameDuration="100" />

It's a simple spinner_white_48.png.旋转动画

Custom android:indeterminateDrawableThe value of rotation animation
<?xml version= "1.0" encoding= "Utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android"Android :p ivotx="50%"android:pivoty= "50%"android:fromdegrees="0" android:todegrees="The" >                    <bitmapandroid:src="@mipmap/icon_timeline_stop_blue"Android:antialias ="true"android:filter="true">                        </bitmap></rotate>

And then

    <ProgressBar        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:indeterminateDrawable="@drawable/loading_anim"        android:id="@+id/progressBar" />

You can make a simple rotation style of the ProgressBar

Frame animation

There is also a style for 帧动画 , here is a bit to note

Two photos, making frame animations

<?xml version= "1.0" encoding= "Utf-8"?><animation-list xmlns:android="Http://schemas.android.com/apk/res/android" android:oneshot="false">        <item android:duration="+">        <clipandroid:cliporientation="Horizontal"android:drawable= "@mipmap/kaoyan_tip_f1" android:gravity="left" />                                        </Item><item android:duration="+">    <clipandroid:cliporientation="Horizontal"android:drawable="@ Mipmap/kaoyan_tip_f2 "android:gravity=" left " />                        </Item></animation-list>

Note that it is necessary to use clip nodes to specify android:clipOrientation and android:gravity="left" , otherwise, different screens may appear incomplete

ProgressBar Styles in Android

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.