android - 在 Xamarin.Forms 中的导航上隐藏 BottomNavigationView(仅限 Android)
问题描述
我正在使用新的 Xamarin.Forms 功能使用以下属性为 Android 设置底部的 Tabbar
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" android:TabbedPage.ToolbarPlacement="Bottom"
导航到其他页面时,我需要隐藏标签栏。我编写了一个从 TabbedPageRenderer 继承的自定义渲染器,但我无法使用 OnElementChanged 获取 BottomNavigationView 的实例。
解决方案
理想情况下,您应该将 TabbedPage 保留在 NavigationPage 中,并将新页面推送到 TabbedPage 之上。
您无法获取 BottomNavigationView 参考,因为它是一个私有字段。虽然,您可以使用反射来设置其值,但我强烈建议您反对。
var info = typeof(TabbedPageRenderer).GetTypeInfo();
var _bottomNavigationView = (BottomNavigationView)info.GetField("_bottomNavigationView", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);`
推荐阅读
- snowflake-cloud-data-platform - 插入时的雪花微分区
- mysql - 在 Mysql Json Collection 数据中搜索
- angular - app-routing 生成触发 auth 服务的新实例
- firebase - 错误:flutter/lib/ui/ui_dart_state.cc(177) 未处理的异常:NoSuchMethodError:方法“插入”在 null 上调用
- java - Java:您调用 Math.random() 的次数是否会影响结果
- java - run方法内部的线程状态冲突;为什么线程状态不是“正在运行”
- ios - 斯威夫特:有没有一种简单的方法可以在 MapKit 中制作一个有效的“位置按钮”?
- opengl - How to instance draw with different transformations for multiple objects
- macos - 为什么 Docker For desktop (Mac) Persistent Volume 主机路径上的 Kubernetes 变得滞后?
- laravel - Laravel Sail 在 Ubuntu 20.04 LTS 中无法正常工作