Hi,
I've got an issue when I use the SetPage() method in my Android MainActivity and try to set a MasterDetailPage. The error message I get is:
Java.Lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY.
I try to implement something similair as this example. However when I try to implement it, I get this error. The strange thing is that this happens even when I have a completely empty MasterDetailPage (except from the required parts). I also tried copying the MasterDetailPage from the example but that didn't work either.
When I use SetPage() to another regular ContentPage, it works fine.
(I am using Xamarin 1.2.2)
The MasterDetailPage, MainPage (PCL)
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="//namespace//.Views.MainPage"
Title="aaaa">
<MasterDetailPage.Detail>
<ContentPage Title="Main">
<ContentPage.Content>
<Label Text="bbbb" />
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Detail>
<MasterDetailPage.Master>
<ContentPage Title="Menu">
<ContentPage.Content>
<Label Text="aaaa" />
</ContentPage.Content>
</ContentPage>
</MasterDetailPage.Master>
</MasterDetailPage>
MainActivity.cs (Android Project)
[Activity(Label = "App Name", MainLauncher = true, Theme = "@android:style/Theme.Holo.Light", ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
public class MainActivity : AndroidActivity, IRootPageManager
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Xamarin.Forms.Forms.Init(this, bundle);
SetPage(App.GetSplashPage(this));
}
public void ShowMainPage()
{
SetPage(App.GetMainPage(this));
}
public void ShowLoginPage()
{
SetPage(App.GetLoginPage(this));
}
}
Stacktrace
0x63 in Android.Runtime.JNIEnv.CallVoidMethod at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:507,138 C#
0x62 in Android.Views.View.Measure at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:12243,1223 C#
0x73 in Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout C#
0xE in Xamarin.Forms.Platform.Android.MasterDetailRenderer.UpdateLayout C#
0x38 in Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.NavigationPage>.OnLayout C#
0x8 in Xamarin.Forms.Platform.Android.NavigationRenderer.OnLayout C#
0x12 in Android.Views.ViewGroup.n_OnLayout_ZIIII at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.ViewGroup.cs:3274,1226 C#
0x2F in object.0b8fcd79-dec6-4fa9-9d9b-be0210db49d3 C#
0x52 in Android.Runtime.JNIEnv.CallVoidMethod at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:503,4 C#
0x87 in Android.Views.ViewGroup.Layout at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.ViewGroup.cs:3046,1226 C#
0x85 in Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout C#
0xE in Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.NavigationPage>.UpdateLayout C#
0xA0 in Xamarin.Forms.Platform.Android.Platform.OnLayout C#
0x1B in Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout C#
0x12 in Android.Views.ViewGroup.n_OnLayout_ZIIII at /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.ViewGroup.cs:3274,1226 C#
0x2F in object.0b8fcd79-dec6-4fa9-9d9b-be0210db49d3 C#