Optimizing drawer and activity launching speed

前端 未结 7 1974
傲寒
傲寒 2020-12-04 07:44

I\'m using the Google DrawerLayout.

When an item gets clicked, the drawer is smoothly closed and an Activity will be launched. Turning thes

相关标签:
7条回答
  • 2020-12-04 08:43

    Google IOsched 2015 runs extremely smoothly (except from settings) the reason for that is how they've implemented the drawer and how they launch stuff.

    First of they use handler to launch delayed:

            // launch the target Activity after a short delay, to allow the close animation to play
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    goToNavDrawerItem(itemId);
                }
            }, NAVDRAWER_LAUNCH_DELAY);
    

    with delay being:

    private static final int NAVDRAWER_LAUNCH_DELAY = 250;
    

    Another thing they do is to remove animations from the activities that are launched with following code inside the activities onCreate():

    overridePendingTransition(0, 0);
    

    To view the source go to git.

    0 讨论(0)
提交回复
热议问题