How can animation of SlidingDrawer?

I am trying to open / close my moving frame with animateOpen() and animateClose() , but it seems to open and close instantly, like open() and close() . What's wrong?

I saw that SlidingDrawer cannot be configured (cannot be animated using special animations, for example, not even with custom open / close durations). Do I need to copy SlidingDrawer code to change 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

Performance

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

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

+6
source share
1 answer

This youtube video shows a sliding box with custom animations. You should be able to use or modify this code to solve your problem ...

+3
source

Source: https://habr.com/ru/post/887749/


All Articles