Android 2d Animation

和自甴很熟 提交于 2020-01-06 19:50:10

问题


I create ImageView with scr run01 (it's first frame of my animation) In drawable I create xml file with this code:

    <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/run01" android:duration="200" />
<item android:drawable="@drawable/run02" android:duration="200" />
<item android:drawable="@drawable/run03" android:duration="200" />
<item android:drawable="@drawable/run04" android:duration="200" />

    </animation-list>

All file .png format I have problem with 2d animation

import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MotionEvent;
import android.widget.ImageView;

public class runImage extends AppCompatActivity {
  AnimationDrawable rocketAnimation;

protected void onWindowFocusChanged(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_run_image);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ImageView rocketImage = (ImageView) findViewById(R.id.run01);
    rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
    rocketAnimation = (AnimationDrawable) rocketImage.getBackground();            }
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        rocketAnimation.start();
        return true;
    }
    return super.onTouchEvent(event);
}

I don't understand misstake: AAPT err(Facade for 826652682): libpng error: Not a PNG file Error:Execution failed for task ':app:mergeDebugResources'.

Some file crunching failed, see logs for details

来源:https://stackoverflow.com/questions/34873184/android-2d-animation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!