【问题标题】:How to custom ActionBar android with Xamarin Forms?如何使用 Xamarin Forms 自定义 ActionBar android?
【发布时间】:2016-04-26 12:33:57
【问题描述】:

我使用 Xamarin 表单。我的 Android 活动扩展了 FormAppCompatActivity。我使用 MasterDetailPage,this.Detail 使用新 NavigationPage(new PagePerso()) 初始化。我有一个 xamarin.forms.view 及其对 Android 的渲染器。 我想把它放在 NavigationBar(Android 的 ActionBar)中。 我尝试使用 NavigationPageRender。然后我尝试使用:

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

提前感谢您的帮助! 如果您有其他解决方案,请建议我! (我使用 Xamarin 表单、FormAppCompat、MasterDetailPage 和 NavigationPage 到它的详细信息)

解决方案和新问题:

我终于来使用 ViewGroup 在 ActionBar 中添加一个 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(); 而且我想以前将视图添加为 viewGroup,但它不是 Android.Views.View。

提前谢谢你!

【问题讨论】:

    标签: android xamarin.forms android-appcompat navigationbar appcompatactivity


    【解决方案1】:

    你试过actionBar.SetDisplayShowCustomEnabled(true);吗?

    我最近看到使用 AppCompat 的这种方法存在一些不一致之处,我正在向 Xamarin 报告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-08
      • 2018-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-14
      • 2019-04-06
      • 1970-01-01
      相关资源
      最近更新 更多