帧一帧动画 [英] Frame-by-frame animations

查看:156
本文介绍了帧一帧动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试codeA逐格动画在Eclipse中,它给我的错误。我发现了一些在互联网上,说他们搞砸了SDK教程文档中,但我不禁想知道机器人:ID =选择的手段或什么应该被放在报价,而不是

When I try to code a frame-by-frame animation in Eclipse, It gives me a bug. I found something on the internet that says they screwed up in the sdk tutorial documentation but I cannot help but wonder what android:id="selected" means or what should be put in the quotations instead.

此外,有人可以解释帧动画教程给我的最后一部分? http://developer.android.com/guide/topics/resources /animation-resource.html#Frame 你把另一个code在文件名的.java,如果是的话,你在哪里把它? 我不明白的地方把第二code,是不是XML。我想我需要知道什么是code以下是和它应该去:

Also, can somebody explain the last part of the frame animation tutorial to me? http://developer.android.com/guide/topics/resources/animation-resource.html#Frame Do you put another code in the filename.Java, and if so, where do you put it? I cannot understand where to put the second code that is not XML. I think I need to know what the code below is and where it should go:

ImageView fileimage = (ImageView) findViewById(R.id.file_image);
fileimage.setBackgroundResource(R.drawable.file_image2);

fileAnimation = (AnimationDrawable)fileimage.getBackground();
fileAnimation.start();

但这里是XML code我用:

But here is the XML code I used:

 <animation-list android:id="selected" android:oneshot="false">
 <item android:drawable="@drawable/filename" android:duration="200" />
 <item android:drawable="@drawable/filename2" android:duration="200" />
 </animation-list>

东西应该被删除或从加进去呢?我不知道自己还能做些什么,因为我需要启动动画,并有code为(一日一),但我不知道它在哪里去,如果我沿着需要另一个code吧。

Should anything be removed or added from that? I don't know what else to do, because I need to start the animation and have the code for that (1st one) but I don't know where it goes, or if I need another code along with it.

推荐答案

这是我是如何实现它。

在你的主要的Java文件,你应该有这样的事情。

In your main java file you should have something like this.

public class Main extends Activity { 
AnimationDrawable mainanimation;

public void onCreate(Bundle icicle) { 
     super.onCreate(icicle); 
     setContentView(R.layout.main);

     ImageView mainimage = (ImageView) findViewById(R.id.MainAnim);
     mainimage.setBackgroundResource(R.anim.mainanim);
     mainanimation = (AnimationDrawable) mainimage.getBackground();

所以,你设置的ImageView在main.xml中布局文件的XML包含动画(R.id.MainAnim)

So you set the ImageView in your main.xml layout file to the xml that contains the animation (R.id.MainAnim)

然后在你的MainAnim.xml(位于RES /阿尼姆)文件写

Then in your MainAnim.xml (located in res/anim) file you write

<?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/image1" android:duration="2000" />
<item android:drawable="@drawable/image2" android:duration="2000" />
</animation-list>

现在image1的和图像2将交替来回在每个2秒。我也没有用的Andr​​iod:ID =选择

Now image1 and image2 will alternate back and forth at 2 seconds each. Also I didn't use andriod:id="selectable".

要回顾一下你需要3个文件。你Main.java,你的main.xml中布局文件,和你的mainanim.xml文件位于RES /阿尼姆。同时您2图像的绘制文件夹。

To recap you need 3 files. Your Main.java, your main.xml layout file, and your mainanim.xml file located in res/anim. Also your 2 images in the drawable folder.

。希望清除它一点。

这篇关于帧一帧动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆