Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中使用XML将动画PNG图像显示到我的版面_Android_Xml_Image - Fatal编程技术网

在android中使用XML将动画PNG图像显示到我的版面

在android中使用XML将动画PNG图像显示到我的版面,android,xml,image,Android,Xml,Image,XML可以用于在我的android布局中显示动画图像吗?我认为您必须根据代码在XML中设置图像动画。您可以获取对png图像的引用并手动设置动画 希望这有助于…布局 <ImageView android:layout_width="82dip" android:layout_height="50dip" android:layout_centerInParent="true" android:background="@drawable/spinner"

XML可以用于在我的android布局中显示动画图像吗?

我认为您必须根据代码在XML中设置图像动画。您可以获取对png图像的引用并手动设置动画

希望这有助于…

布局

<ImageView
    android:layout_width="82dip"
    android:layout_height="50dip"
    android:layout_centerInParent="true"
    android:background="@drawable/spinner"
    android:id="@+id/splashSpinner"/>

我知道,但我需要播放一个GIF文件。你的问题不是在谈论GIF。。。无法在android项目中添加gif。请轻松获取动画gif并在adobe photoshop中打开。它将显示所有图层。将每个层另存为png文件。然后使用这个响应中的示例来设置PNG的动画。我有一个图像,精确地说是“气球”图像。我需要创建大约600个这样的图像,然后在屏幕上随机设置动画。我能够制作动画,但它使用了大约300Mb的内存。有没有一种标准的优化方法可以做到这一点?
<?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/anim__000" android:duration="100" />
    <item android:drawable="@drawable/anim__001" android:duration="100" />
    <item android:drawable="@drawable/anim__002" android:duration="100" />
    <item android:drawable="@drawable/anim__003" android:duration="100" />
    <item android:drawable="@drawable/anim__004" android:duration="100" />
    <item android:drawable="@drawable/anim__005" android:duration="100" />
    <item android:drawable="@drawable/anim__006" android:duration="100" />
    <item android:drawable="@drawable/anim__007" android:duration="100" />
    <item android:drawable="@drawable/anim__008" android:duration="100" />
    <item android:drawable="@drawable/anim__009" android:duration="100" />
    <item android:drawable="@drawable/anim__010" android:duration="100" />
    <item android:drawable="@drawable/anim__011" android:duration="100" />
</animation-list>
    this.spinner = this.view.findViewById(R.id.splashSpinner);

    this.spinner.post(new Runnable()
    {
        @Override
        public void run()
        {
            AnimationDrawable spinnerAnim = (AnimationDrawable) spinner.getBackground();
            if (!spinnerAnim.isRunning())
            {
                spinnerAnim.start();
            }
        }
    });