帧动画

MainActivity.java

public class MainActivity extends Activity {
    private ImageView iv_show;
    private AnimationDrawable animationDrawable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv_show = (ImageView) findViewById(R.id.iv_show);
        iv_show.setBackgroundResource(R.drawable.girl_show);
        //得到动画资源对象
        animationDrawable = (AnimationDrawable) iv_show.getBackground();
    }

    public boolean onTouchEvent(MotionEvent event) {
          if (event.getAction() == MotionEvent.ACTION_DOWN) {
              animationDrawable.start();
            return true;
          }
          return super.onTouchEvent(event);
        }
}

activity_main.xml



    


girl_show.xml



    
    
    
    
    
    
    
        
    
        
    
    
    
    
    


你可能感兴趣的:(帧动画)