Frame-By-Frame Animations的使用方法
来源:互联网 发布:个人工作计划安排软件 编辑:程序博客网 时间:2024/06/05 02:51
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android"android:oneshot="false"><item android:drawable="@drawable/nv1" android:duration="500" /><item android:drawable="@drawable/nv2" android:duration="500" /><item android:drawable="@drawable/nv3" android:duration="500" /><item android:drawable="@drawable/nv4" android:duration="500" /></animation-list>
首先是建在res的drawable目录下面建一个 anmi_nv.xml文件,再写上上面的配置。
下面是MainActivity:
package mars.animations05;import android.app.Activity;import android.graphics.drawable.AnimationDrawable;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ImageView;public class MainActivity extends Activity {private Button button = null;private ImageView imageView = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); imageView = (ImageView)findViewById(R.id.imageViewId); button = (Button)findViewById(R.id.buttonId); button.setOnClickListener(new ButtonListener()); } private class ButtonListener implements OnClickListener{public void onClick(View v) {imageView.setBackgroundResource(R.drawable.anim_nv);AnimationDrawable animationDrawable = (AnimationDrawable)imageView.getBackground();animationDrawable.start();} }}
main.xml:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent"><Button android:id="@+id/buttonId" android:layout_width="fill_parent"android:layout_height="wrap_content" android:layout_alignParentBottom="true"android:text="测试动画效果" /><LinearLayout android:orientation="vertical"android:layout_width="fill_parent" android:layout_height="fill_parent"><ImageView android:id="@+id/imageViewId"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_centerInParent="true" android:layout_marginTop="100dip"/></LinearLayout></RelativeLayout>
mars老师的视频,第二季。
- Frame-By-Frame Animations的使用方法
- Animations之Frame-By-Frame Animations的使用方法
- Frame By Frame Animations
- Android常用动画Frame-By-Frame Animations的使用
- Android之Frame By Frame Animations
- Android Animation动画(Frame-By-Frame Animations 、Tween Animations 、Property Animation)的详解
- 帧动画Frame-by-Frame Animation的使用方法
- android Frame-By-Frame Animations(一帧一帧地播放动画)的使用
- android中animation之Frame-By-Frame Animations
- UIView Key-frame Animations
- UIView Key-frame Animations
- 安卓动画之逐帧动画Frame-by-frame Animations详解
- Delphi中Frame的使用方法
- frameset和frame的使用方法
- frameset和frame的使用方法
- frameset和frame的使用方法
- Delphi中Frame的使用方法
- Frame-by-frame animation实例
- 《30天精通iPhone手机编程》-Day21-音乐选播器
- 抽象方法(abstract class)的作用体现
- c++中new和delete的那些事1
- TCP协议理解
- STL中的常用的vector,map,set,Sort用法
- Frame-By-Frame Animations的使用方法
- C#字符串和正则表达式参考手册(笔记)
- servlet非线程安全,解决办法
- [python学习]列表复制
- 使用wireshark分析网络报文
- C#创建动态数组
- 某些网站
- 使用neoclipse
- Exchange Server2010的部署规划(一)