您可以查看DrawerLayout,将菜单设置为从右到左打开。
您应该设置android:layout_gravity
和tools:openDrawer="end"
例如:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_gravity="right"
tools:openDrawer="end">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|end"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
您的活动中:
DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
if(drawer.IsDrawerOpen(GravityCompat.End))
{
drawer.CloseDrawer(GravityCompat.End);
}
else
{
base.OnBackPressed();
}
效果类似:
您也可以参考native android case