我的项目是一个静态的Android应用程序,现在已经完成,用户需要动画主页中的所有按钮点击。我构建了一个单独的项目并动态完成动画。
问题是:
1) The animation works alternatively in sample project. ie When the project is first activated the animation doesn't work and when its closed and restarted the animation works.
2) This animation on being added to the main project fails altogether. As in the animation doesn't work but the intent works and the app moves to next activity without issues.(there is a time delay. before the activity moves to next )
我的问题是
1) why is animation not working properly?
2) why does same code not produce any animation in main project?
我的代码如下..
public class Button_Anime extends Activity{
private static int SPLASH_TIME_OUT = 550;
AnimationDrawable animate= new AnimationDrawable();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
//String values = intent.getStringExtra("Value");
setContentView(R.layout.activity_splash_about);
RelativeLayout lay = (RelativeLayout) findViewById(R.id.relLayButtonAnime);
ImageView loading =(ImageView) findViewById(R.id.iVArcRail_2);
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 32;
options.inPurgeable = true;
options.inScaled = true;
Bitmap b;
Drawable d;
int i =50;
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab1, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab2, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab3, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab4, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab5, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab6, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab7, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab8, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab9, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
b = BitmapFactory.decodeResource(getResources(),R.drawable.ab10, options);
d = new BitmapDrawable(getResources(),b);
animate.addFrame(d, i);
loading.setBackgroundDrawable(animate);
loading.post(new Refiney());
System.gc();
Timer timer = new Timer();
TimerTask timertask = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
Intent intent = new Intent(Button_Anime.this, Home.class);
startActivity(intent);
}
};
timer.schedule(timertask, SPLASH_TIME_OUT);
Button_Anime.this.finish();
//main(values);
}
class Refiney implements Runnable {
public void run() {
animate.start();
}
}
}