动画不能正常工作

时间:2014-06-14 02:23:33

标签: android animation

在我的项目中,动画每隔一段时间工作。当prg第一次运行时,动画不会工作..但是如果你关闭应用程序并再次运行它,动画就可以了..为什么会这样?这是我的班级文件 samplesize已经处于最低限度..任何其他技术??

  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");
    System.gc();
    setContentView(R.layout.activity_splash_about);
    System.gc();
    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);
    System.gc();
    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();   
    }
}

}

0 个答案:

没有答案