I’m migrating from Xamarin to MAUI and i have a native Android layout that i use to take photos. In Xamarin i use a PageRenderer and on the OnElementChanged event i assign the view:

view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
AddView(view);

In MAUI Android i’ve attempted to do what i believe is the same. I inherit from PageHandler:

handlers.AddHandler(typeof(Views.CameraPage), typeof(Platforms.Android.Renderers.CameraPageRenderer));

protected override void ConnectHandler(ContentViewGroup platformView)
{
    base.ConnectHandler(platformView);
    var view = activity.LayoutInflater.Inflate(Resource.Layout.Test, platformView, false);
    platformView.AddView(view);
}

I can see the code being executed without any errors but the screen is always blank. I’ve no issues in iOS however with this code:

[code to create view]
MainView = VirtualView.ToPlatform(MauiContext);
MainView.Add(newView);

I’ve tried manually coding a simple View in Android rather than reading from resource axml but with the same issue. I can see examples for content view / control renderers on Microsoft web resources but can’t find an example for PageRenderer. Help appreciated.

New contributor

user24004541 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.