在Android应用中可以通过AnimationDrawable轻松实现View的动画效果,这个比播放png图片要简单得多,具体看代码:
private void startSinalAnimation( View view ) throws NullPointerException{
if( null == view ){
throw new NullPointerException( "入参为空" );
}
view.setBackgroundResource( R.anim.battery_animation );
mSingalAnimation = ( AnimationDrawable )view.getBackground( );
mSingalAnimation.start( );
}
private void stopSingalAnimation( View view ) throws NullPointerException{
if( null == view ){
throw new NullPointerException( "入参为空" );
}
if( null != mSingalAnimation && mSingalAnimation.isRunning( ) ){
mSingalAnimation.stop( );
}
view.setBackgroundResource( R.drawable.stat_sys_battery_charge_anim0 );
}
代码下载地址:Android应用通过AnimationDrawable实现View的动画效果
AnimationDrawable的使用方法参见:AniamtionDrawable