【问题标题】:CustomView in ActionBar disappear when orientation change ? (AppCompat)当方向改变时,ActionBar 中的 CustomView 会消失吗? (AppCompat)
【发布时间】:2016-07-08 06:53:40
【问题描述】:

问题:

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

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

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

【问题讨论】:

  • 这是基于Xamarin.Forms 的应用程序吗?还是基于Xamarin.Android
  • 这是一个基于 Xamarin.Forms 的应用程序。

标签: xamarin android-actionbar android-appcompat custom-view viewwilldisappear


【解决方案1】:

最后我通过工具栏的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);

当我们使用 AppCompat 时,使用的是工具栏。 然后,我删除视图并再次添加我的 CustomView。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    相关资源
    最近更新 更多