在xml中定义<animation-list.../> 轮换定义在其中图片资源
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<!--
oneshot = true 表示只执行一次,item依次执行
false 表示循环执行,
-->
<item
android:drawable="@drawable/a11"
android:duration="1200"/>
<!-- duration 图片显示的持续时间 -->
<item
android:drawable="@drawable/a2"
android:duration="1200"/>
<item
android:drawable="@drawable/a3"
android:duration="1200"/>
</animation-list>
package com.stone.ui;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.stone.R;
public class AnimationActivity extends Activity {
ImageView imageview;
AnimationDrawable drawable1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.animation_main);
imageview = (ImageView) findViewById(R.id.imageview);
drawable1 = (AnimationDrawable) getResources().getDrawable(R.drawable.drawable1);
imageview.setBackgroundDrawable(drawable1);
}
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
drawable1.start();
return true;
}
return super.onTouchEvent(event);
}
@Override //window焦点改变 使动画自动开始
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
//start不能直接用在onCreate中,因为此时,AnimationDrawable还没有完全在window中建立好。
drawable1.start();
}
}
}
分享到:
相关推荐
基本动画案例:Tween Animation, Frame Animation,介绍参考:http://blog.csdn.net/forwardyzk/article/details/42739281
Android frame by frame animation动画显示源代码
自己写的一个帧动画Demo,没啥技术含量,只是方便需要的人。
FrameAnimation 用TextureView或SurfaceView 高性能播放帧动画,避免在很多帧的情况下使用AnimationDrawable带来的OOM和卡顿问题。 华为 mate 20X 1920×1080 24bit color JPG 201frames 24fps 测试效果 download ...
上次提供了Animation动画其一Tween补间动画的源代码,这次提供其二Frame动画的源代码(以直接编码的形式实现Frame动画的Demo,笔者资源中另有以xml形式实现的Demo)。
这个 FrameAnimation(安卓动画) ,适合新手学习和借鉴。里面有wifi信号动画 和 DNF 狂战士 上挑加下斩动画
Drawable Animation / 帧动画 / Frame 动画 English explanation can go to read this article Ⅲ. Property Animation / 属性动画 English explanation can go to read this article Ⅳ. Ripple Effect / Touch ...
上次提供了Animation动画其一Tween补间动画的源代码,这次提供其二Frame动画的源代码(以xml形式实现的Demo。笔者资源中另有以直接编码的形式实现Frame动画的Demo)。
包含AlphaAnimation渐变效果 TranslateAnimation:位移渐变 ScaleAnimation:缩放渐变 RotateAnimation:旋转渐变 AnimationSet:组合渐变... frameAnimation:帧动画的xml和代码实现方式,非常适合新手朋友参考。
Android 动画,FrameAnimation, 帧动画,光晕效果
Android动画之Animation的使用。包括变换动画Tween Animation,帧动画Frame Animation,布局动画Layout Animation,属性动画Property Animation
android 动画 资源,一步一步实现android FrameAnimation 动画,让你不再为动画烦恼。
Android Animation的简单Demo 相应博客地址:http://blog.csdn.net/u011268102/article/details/9707071
Andorid帧动画,也称为Frame动画,为Android3.0前的主要动画之一,这里主要实现了静态、动态实现的俩种方式,顺带实现了当前美团中使用的加载中... 小人奔跑动画 ~
NULL 博文链接:https://wangleyiang.iteye.com/blog/1714229
在代码中定义逐帧动画。WIFI信号显示。适用于初学者。
在Android中,动画Animation的实现有两种方式:Tween Animation(补间动画)和Frame Animation(帧动画)。渐变动画是通过对场景里的对象不断做图像变换(平移、缩放、旋转等)产生动画效果。帧动画则是通过顺序播放...
一个动态表情的例子,快速了解帧动画的使用.
View Animation Only animate View objects If animate non-view objects, you have to implement your own code takes less time to setup and ...Load drawable resources and display them one frame after another
来自同事_Smile的封装应用,记录学习一下,分享给大家,具体如下: 1、... private AnimationDrawable frameAnimation; public AnimImageViewLoader(Context context, AttributeSet attrs, int defS