import flash.net.FileReference;
import flash.system.System;
var xs:XML =<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"></animation-list>;
var nss:Namespace=new Namespace("android","http://schemas.android.com/apk/res/android");
xs.addNamespace(nss);
for(var i:int=0;i!=10;i++){
xs.appendChild(<item />);
//xs.@drawable="@drawable/pic_"+i;
}
var slen:int=-1;
for each(var ml:XML in xs.elements()){
slen=slen+1;
ml.@drawable="@drawable/s/color_000"+slen;
ml.@duration=50;
ml.@drawable.setNamespace(nss);
ml.@duration.setNamespace(nss);
}
var f:FileReference=new FileReference();
f.save(xs,"anim_.xml");
android代码
package com.example.app_ui_test;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
/**
* Created with IntelliJ IDEA.
* User: Administrator
* Date: 14-7-16
* Time: 下午12:46
* To change this template use File | Settings | File Templates.
*/
public class maintest extends Activity {
private ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); //To change body of overridden methods use File | Settings | File Templates.
setContentView(R.layout.lo_maintest);
iv=(ImageView)findViewById(R.id.imageView);
iv.setBackgroundResource(R.drawable.anim);
Object bo=iv.getBackground();
AnimationDrawable ad=(AnimationDrawable)bo;
ad.setOneShot(true);
ad.start();
}
}
做了一个小软件以供生成android xml动画序列文件。从这里下载。
标签:动画,配置文件,ml,import,var,xs,android,drawable From: https://blog.51cto.com/u_15932543/5994476