2
votes

I work with Xamarin Forms. My Android activity extends FormAppCompatActivity. I use a MasterDetailPage and this.Detail is init with new NavigationPage(new PagePerso()). I have a xamarin.forms.view and its renderer to Android. I would like put this inside the NavigationBar (ActionBar to Android). I tried to use a NavigationPageRender. Then I tried to use :

protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e){ base.OnElementChanged(e); Android.Views.View actionBar = base.ViewGroup.GetChildAt(0); ...}

Thanks you in advance for your help ! If you have an other solution, suggest me ! (I use Xamarin forms, FormAppCompat, MasterDetailPage and NavigationPage to its Detail)

Solution and new problem :

I have finally come to add an Android.View inside ActionBar using ViewGroup. Now, my problem is that I want to add a custom view (xamarin) ...

Android.Widget.Button bt = new Android.Widget.Button(base.ViewGroup.Context); ViewGroup actionBar = (ViewGroup) base.ViewGroup.GetChildAt(0); actionBar.AddView(viewGroup); The button with this code is added well.

So I have MyCustomView view = new MyCustomView(); And I would like add view as viewGroup previously but it's not an Android.Views.View.

Thanks you in advance !

1

1 Answers

0
votes

Have you tried actionBar.SetDisplayShowCustomEnabled(true);?

I have recently seen some inconsitencies with this approach using AppCompat that I'm about the report to Xamarin.