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。