导航抽屉的自定义动画

时间:2014-04-23 15:07:58

标签: android animation menu navigation-drawer

我按照here的说明成功实施了导航抽屉 现在,我想覆盖打开/关闭的默认动画。我想使用自定义动画。这可行吗?如果是这样,我该怎么办?非常感谢你

1 个答案:

答案 0 :(得分:0)

您可以在DrawerLayout上调用openDrawer(int gravity),使其以动画方式打开抽屉。

示例:

// 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);
        }
    }
}