简体   繁体   English

导航抽屉的自定义动画

[英]Custom animation for navigation drawer

I've successfully implemented the Navigation Drawer as explained here Now, I'd like to override the default animation for opening/closing. 我已经成功地实施了抽屉式导航栏作为解释这里现在,我想重写用于开启/关闭默认的动画。 I'd like to use a custom animation. 我想使用自定义动画。 Is it feasible? 这可行吗? If so, how can I do it? 如果是这样,我该怎么办? Thank you very much 非常感谢你

You can call openDrawer(int gravity) on the DrawerLayout to make it open the drawer with an animation. 您可以在DrawerLayout上调用openDrawer(int gravity),使其通过动画打开抽屉。

Example: 例:

// Delay is in milliseconds
static final int DRAWER_DELAY = 200;

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    // Building NavDrawer logic here. Just a method call would be best.
    ...
    new Handler().postDelayed(openDrawerRunnable(), DRAWER_DELAY);
}

private Runnable openDrawerRunnable() {
    return new Runnable() {

        @Override
        public void run() {
            drawerLayout.openDrawer(Gravity.LEFT);
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM