2

我使用Xamarin Forms。我的Android活動擴展了FormAppCompatActivity。我使用了一個MasterDetailPage,並且這個.Detail是帶有新的NavigationPage(新的PagePerso())的init。我有一個xamarin.forms.view和它的渲染器到Android。 我想把這裏面的NavigationBar(ActionBar到Android)。 我試圖使用NavigationPageRender。然後我試圖使用方法:如何使用Xamarin Forms自定義ActionBar android?

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

謝謝你提前爲您的幫助! 如果您有其他解決方案,建議我! (我用Xamarin形式,FormAppCompat,MasterDetailPage和NavigationPage其詳細信息)

解決方案和新的問題:

我終於來使用ViewGroup中添加一個Android.View內動作條。現在,我的問題是,我想添加一個自定義視圖(xamarin)...

Android.Widget.Button bt = new Android.Widget.Button(base.ViewGroup.Context); ViewGroup actionBar = (ViewGroup) base.ViewGroup.GetChildAt(0); actionBar.AddView(viewGroup); 帶有此代碼的按鈕已添加好。

所以我有MyCustomView view = new MyCustomView(); 我想先添加view作爲viewGroup,但它不是Android.Views.View。

謝謝你提前!

回答

0

你試過actionBar.SetDisplayShowCustomEnabled(true);

我最近看到了一些與使用AppCompat的方法不一致的地方,那就是我關於Xamarin的報告。