I am trying to show search view on navigation bar in my xamarin.forms project for Android. But the search toolbar item (search icon) is not visible on android 7.0 and above which works fine on android 6.0.
I have followed this link to write custom renderer for a content page. It works fine on android 6.0.
On searching further, I got this link which is working fine if I create xamarin.android project but the same is not working on xamarin.forms.
Here is my MainActivity code:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
public static Android.Support.V7.Widget.Toolbar ToolBar { get; private set; }
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
public override bool OnCreateOptionsMenu(IMenu menu)
{
ToolBar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
return base.OnCreateOptionsMenu(menu);
}
}