2

I am currently using the master-detail page in xamarin.forms using MVVMlight and it renders based on the default behavior of os it renders perfectly what I wanted but in android master page starts below the navigation bar. I wanted master page to cover full height of screen just like ios do so is there any way or solution for it without custom renderer or is it necessary to write custom renderer for this

Kindle Q
  • 944
  • 2
  • 19
  • 28
Jay Patel
  • 528
  • 8
  • 26
  • for android you can put Theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen") in your activity – Slepz Jan 20 '16 at 20:20
  • in that case navigation bar will not be visible but i want navigation bar to be visible as well – Jay Patel Jan 22 '16 at 16:14
  • you said you wanted full screen – Slepz Jan 22 '16 at 16:15
  • i want master page to take full screen not detail page – Jay Patel Jan 22 '16 at 16:18
  • hmm well I'm not sure how to do that but I know there are flags you can set on android that will show/hide the nav bar. http://developer.android.com/training/system-ui/navigation.html has more info. You might be able to set up a "showing full screen" event and "exiting full screen" event in your forms project and implement them in the android project to set these flags. – Slepz Jan 22 '16 at 16:23
  • its okay if i am not able to cover navigation bar but can i make my master page similar to gmail navigation drawer? – Jay Patel Jan 22 '16 at 16:27

2 Answers2

1

Use FormsAppCompatActivity instead of FormsApplicationActivity.

enter image description here

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());
        }
    }
Jay Patel
  • 528
  • 8
  • 26
  • Can I have the same drawer, for the activity derived from FormsApplicationActivity instead of FormsAppCompatActivity? – Shyam Oct 10 '17 at 07:28
  • It is difficult to create the similar drawer with FormsApplicationActivity as you have to write custom project level code and it is very complex especially for navigation drawer. – Jay Patel Oct 10 '17 at 13:36
0

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/

Mark Dail
  • 501
  • 4
  • 10