在创建一个Android的帧动画 [英] Creating a frame animation in android

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

问题描述

嗨即时试图建立一个帧动画的一系列图像作为一个Android应用程序为我的形象页面的背景下,我想如果可能像code上运行启动。我一直在写了code,但得到,说:帧动画不能得到解决的错误。

Hi im trying to set up a frame animation with a series of images as a background for my splash page in an android application, I would if possible like the code to run on start up. I have been writing the code but get an error that says "frame animation cannot be resolved".

化java code我在我的主要活动实施如下:

The java code I have implemented in my main activity is as follows:

@Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ImageView frameanimation = (ImageView) findViewById(R.id.frame_animation);
        AnimationDrawable frame_animation = (AnimationDrawable) frameanimation.getBackground();

        frame_animation.setVisible(true, true);
        frame_animation.start();
    }

然后我有这个code我的XML布局文件中实现的成像图:

I then have this code implementing an image view within my XML Layout file:

<ImageView
        android:id="@+id/frame_animation"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:src="@drawable/frame_animation" />

终于我有我的动画绘制保存为我绘制文件夹中的frame_animation.xml。

and finally I have my animation drawable saved as 'frame_animation.xml' within my drawable folder.

<?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/homebckgrnda1" android:duration="200" />
    <item android:drawable="@drawable/homebckgrnda2" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda3" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda4" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda5" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda6" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda7" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda8" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda9" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda10" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda11" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda12" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda13" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda14" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda15" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda16" android:duration="50" />
    <item android:drawable="@drawable/homebckgrnda17" android:duration="50" />
</animation-list>

任何帮助很多AP preciated,我想不出什么错误。

Any help is much appreciated, I just cannot figure out what is going wrong.

感谢

推荐答案

ImageView的来源(的android:SRC )和ImageView的(的android背景:背景)是不同的东西。您正在设置的来源在XML中,但试图让在背景在code(图片 frameanimation.getBackground())。

Source of ImageView (android:src) and background of ImageView (android:background) are different things. You are setting the source in XML but trying to get the background image in the code (frameanimation.getBackground()).

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

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