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