0

问题:定位更改时,ActionBar中的CustomView会消失吗? (AppCompat)

我个性化我的actionBar(SupportActionBar)与我的CustomNavigationPage上的渲染器,因为我使用AppCompat主题。所以,我在这个类的操作栏中添加了我的CustomView(一个SearchBar)。

但是,当我们改变方向(纵向 - >横向/横向 - >纵向)时,我的视图消失,如果我想再次查看我的CustomView,我必须重新创建我的CustomNavigationPage。

我需要你的帮助,提前谢谢!

+0

这是一个'Xamarin.Forms'应用程序吗?或'Xamarin.Android'为基础? – SushiHangover

+0

这是一个基于Xamarin.Forms的应用程序。 –

回答

0

最后,我通过工具栏的ID解决了这个问题:

 int toolbarId = Resources.GetIdentifier("toolbar", "id", Android.App.Application.Context.PackageName); 
     Android.Support.V7.Widget.Toolbar actionBar = (Android.Support.V7.Widget.Toolbar)FindViewById(toolbarId); 

当我们使用程序兼容性,这是所使用的工具栏。 然后,我删除视图并再次添加我的CustomView。