Android uses animation-list to animate frames by frame

Source: Internet
Author: User

The effect we want to achieve

Prepare the resource file to dropres/drawableIn the file


Light01.png

Light02.png

Light03.png

Writeloading.xmlPut inres/drawable
<!--animation-list: Root tag oneshot: Indicates whether to show only once, set to false will not stop the animation of the animated Android:d Uration represents the animation of the picture time---   <?xml version= "1.0" encoding= "Utf-8"?><animation-list xmlns:android="Http://schemas.android.com/apk/res/android" android:oneshot="false" >        <itemandroid:drawable="@drawable/light01"android:duration="50" />                    <itemandroid:drawable= "@drawable/light02"android:duration=" "/>                    <itemandroid:drawable="@drawable/light03"android:duration= "/>"                </animation-list>
Inactivity_main.xmlLayout file, so write
<?xml version= "1.0" encoding= "Utf-8"?><linearlayout xmlns:android="Http://schemas.android.com/apk/res/android"  Android:layout_width="Fill_parent"android:layout_height="Fill_parent"  Android:orientation="vertical">             <imageview  android:id  = "@+id/main_img_loading"  android:layout_wid th  = "wrap_content"  android:layout_height= "wrap_content"  android:padding  = "5px"  android:src  = "@drawab Le/loading "/>      <button  android:id  = "@+id/main_bt_start"  android:layout_width< /span>= "wrap_content"  android:layout_height  = "wrap_content"  android:padding  = "5px"  android:text  = "start"  />     <button android:id="@+id/main_bt_stop"android:layout_width="Wrap _content "android:layout_height=" Wrap_content "android:padding=" 5px " Android:text="Stop" />                                </linearlayout>
In the activity, write like this.
Bt_start.setonclicklistener (NewOnclicklistener () {@Override       Public void OnClick(View v) {//Get animationdrawableAnimationdrawable = (animationdrawable) animationiv.getdrawable ();//Start animationAnimationdrawable.start ();   }  }); Bt_stop.setonclicklistener (NewOnclicklistener () {@Override       Public void OnClick(View v) {//Get animationdrawableAnimationdrawable = (animationdrawable) animationiv.getdrawable ();//Stop animationAnimationdrawable.stop (); }  });

Interested children's shoes can follow my blog, my column will continue to update the Android Studio authoritative tutorial, as well as I/O assembly on the NDK configuration and compilation, I will also share to everyone.
And I received an invitation from CSND's instructor, and later I'll record the use of these Android studio videos.

/** * -------------- * 欢迎转载   |  转载请注明 * -------------- * 如果对你有帮助,请点击|顶| * -------------- * 请保持谦逊 | 你会走的更远 * -------------- * @author zsl * @github https://github.com/yy1300326388 * @blog http://blog.csdn.net/yy1300326388 */

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android uses animation-list to animate frames by frame

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.