Gmail就像xamarin.forms中的导航抽屉(母版页)一样

时间:2016-01-20 19:21:34

标签: xamarin xamarin.forms navigation-drawer xamarin.mobile

我目前正在使用MVVMlight在xamarin.forms中使用master-detail页面,它根据os的默认行为呈现它完全呈现我想要的但是在android主页面从导航栏下面开始。我希望主页覆盖屏幕的全高,就像ios那样,没有自定义渲染器有没有任何方法或解决方案,或者是否需要为此编写自定义渲染器

2 个答案:

答案 0 :(得分:1)

使用FormsAppCompatActivity而不是FormsApplicationActivity。

enter image description here

定义你自己的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>

设置您自己的工具栏资源

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

答案 1 :(得分:0)

是的,你可以。检查这些链接。他们都使用MasterDetail页面来创建导航抽屉。只有Detail页面成为主页面视图,Master页面成为滑动菜单。它实际上相当简单。还有其他几个很好的例子。但是我认为你可以通过我列出的3个链接完成工作。如果没有尝试搜索,如何在Xamarin表单中创建导航抽屉。

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/

相关问题