6

I try to open/close my slidingdrawer with animateOpen() and animateClose(), but it seems it opens and closes instantaneously, like open() and close(). What's wrong?

I've seen that SlidingDrawer can't be customized (can't be animated with custom animation for instance, even not with custom open/close duration). Do I have to copy SlidingDrawer's code just to change the animation duration?

Thanks

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.home);        

    // Open and close banner
    final SlidingDrawer banner = (SlidingDrawer) findViewById(R.id.banner);
    banner.animateOpen();
    Handler handler = new Handler(); 
    handler.postDelayed(new Runnable() { 
         public void run() { 
              banner.animateClose();
         } 
    }, 2000); 

    //...

}

EDIT

Doing

final SlidingDrawer banner = (SlidingDrawer) findViewById(R.id.banner);
final Animation hideBanner = AnimationUtils.loadAnimation(this, R.anim.hide_banner);
banner.setAnimation(showBanner);

animates the handler only, even though I don't do banner.animateOpen() or banner.startAnimation(showbanner)!

jul
  • 36,404
  • 64
  • 191
  • 318
  • Try using setAnimation(...) to set an animation on your banner object before using animateOpen() / animateClose() – Squonk May 10 '11 at 18:13
  • I tried: only the handler is animated. The content is not visible :( – jul May 11 '11 at 09:10

1 Answers1

3

This youtube video shows a sliding drawer with a custom animation. You should be able to use or modify this code to solve your issue...

starkej2
  • 11,391
  • 6
  • 35
  • 41