Gmail like navigation drawer (master page) in xamarin.forms

旧城冷巷雨未停 提交于 2019-12-02 02:28:48

Use FormsAppCompatActivity instead of FormsApplicationActivity.

define your own toolbar.axml

toolbar.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    android:contentInsetStart="0dp"
    android:contentInsetLeft="0dp"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways">
</android.support.v7.widget.Toolbar>

Set your own ToolbarResource

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            ToolbarResource = Resource.Layout.toolbar;
            base.OnCreate(bundle);
            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
    }

Yes you can. Check these links. They all use the MasterDetail page to create a Navigation Drawer. Only the Detail page becomes the main page view and the Master page becomes the sliding Menu. It is actually fairly simple. There are a couple of other good example out there also. However I think you can get the job done from the 3 links I listed. If not try a Search like How can I create a Navigation Drawer in Xamarin Forms.

http://www.meritsolutions.com/mobile-development/implementing-navigation-drawer-in-xamarinforms/

https://www.syntaxismyui.com/xamarin-forms-masterdetail-page-navigation-recipe/

http://blog.falafel.com/xamarin-creating-a-sliding-tray/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!