读书人

关于Android下Animation的复用的想法

发布时间: 2012-09-09 09:27:54 作者: rapoo

关于Android上Animation的复用的想法
1.效果都搞成xml
例如:

a. scale_in.xml (表示 scale 的进入效果)
b. scale_out.xml (表示 scale 的out效果)

2.将定义的格式各样的效果都放到一个类里,随机调用效果

public class AnimUtils {private static  int[] effect_out = new int[]{R.anim.alpha_out, R.anim.reverse_out,  android.R.anim.slide_out_right,R.anim.rotate_out,R.anim.rotate_left_out,R.anim.scale_out,R.anim.zoom_out};private static int[] effect_in = new int[]{R.anim.alpha_in, R.anim.reverse_in,  android.R.anim.slide_in_left,R.anim.rotate_in,R.anim.rotate_left_in,R.anim.scale_in,R.anim.zoom_in};private static final String TAG="debug";public static void RandomAnim(Activity ct) {final Random random = new Random();int temp = (int) (random() * 10)+1;//int id = 10 % temp;Log.d(TAG,"Anim index id : "+temp);Log.d(TAG,"Anim in id : "+effect_in[random.nextInt(effect_in.length)]);ct.overridePendingTransition(effect_in[random.nextInt(effect_in.length)], effect_out[random.nextInt(effect_out.length)]);// return 0;}}


3.嗯,这样很方便
参考:http://flyouting.iteye.com/blog/1054703

读书人网 >Android

热点推荐