Android learning --- create Frame Animation

Source: Internet
Author: User

1. First layout the file in aime_activity.xml


<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent" ><ImageView        android:id="@+id/Img_center"        android:layout_width="50dp"        android:layout_height="50dp"        android:layout_centerHorizontal="true"        android:layout_centerVertical="true"/></RelativeLayout >

2. Create an anim. xml Frame Animation File


<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" >    <item android:drawable="@android:drawable/star_big_off" android:duration="50"/>    <item android:drawable="@android:drawable/star_big_on" android:duration="50"/></animation-list>

Note: The duration Attribute indicates the display time of each item.


3. java File

Img1=(ImageView)this.findViewById(R.id.Img_center);Img1.setBackgroundResource(R.drawable.login_img);Img1.setVisibility(ImageView.VISIBLE);AnimationDrawable frameAnimation =                    (AnimationDrawable)Img1.getBackground();frameAnimation.stop();frameAnimation.start();


This article is from the "7603943" blog, please be sure to keep this source http://7613943.blog.51cto.com/7603943/1284321

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.