优化导航抽屉关闭速度 - Xamarin Android
问题描述:
我想优化导航抽屉关闭的速度。在我的导航抽屉中,当我点击一个项目时,它导航到不同的活动,但导航速度不是很快(与点击导航抽屉外部时如何关闭的速度相比,它关闭非常平滑)。优化导航抽屉关闭速度 - Xamarin Android
如何在新活动显示之前使导航抽屉非常平滑地关闭?
这是我结束我的导航栏打开新的活动
private void SetUpDrawerContent(NavigationView navigationView)
{
navigationView.NavigationItemSelected += (object sender, NavigationView.NavigationItemSelectedEventArgs e) =>
{
int id = e.MenuItem.ItemId;
switch (id)
{
case Resource.Id.nav_1:
Intent intent = new Intent(this, typeof(activity1));
this.StartActivity(intent);
GC.Collect();
break;
case Resource.Id.nav_2:
if (user != null)
{
Intent events = new Intent(this, typeof(EventActivity));
this.StartActivity(events);
GC.Collect();
}
else {
Intent loginEvent = new Intent(this, typeof(LoginActivity));
this.StartActivity(loginEvent);
}
break;
}
e.MenuItem.SetChecked(true);
mDrawerLayout.CloseDrawers();
};
}
答
我建议你延迟一个选择的动作的执行,直到抽屉被关闭。所以,一旦用户点击导航项目,你应该记住他的选择,关闭抽屉,并在该过程之后才选择。