如何在 Xamarin.Forms.Maps 中使用暗模式 Google 地图? [英] How to use Dark Mode Google Maps in Xamarin.Forms.Maps?

查看:44
本文介绍了如何在 Xamarin.Forms.Maps 中使用暗模式 Google 地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Xamarin.Forms.Maps nuget 包在我的 Xamarin.Forms 应用程序中使用暗模式 Google 地图.

I'm trying to use the Dark Mode Google Maps in my Xamarin.Forms app using the Xamarin.Forms.Maps nuget package.

我已经在 OnElementChanged if(e.NewElement != null) 方法中使用 CustomRenderer 中的这行代码成功地在 iOS 地图上设置了暗模式:

I've managed to have Dark Mode on iOS Maps using this line of code in the CustomRenderer in the OnElementChanged if(e.NewElement != null) method:

nativeMap.OverrideUserInterfaceStyle= UIUserInterfaceStyle.Dark;

但是我一直无法在 Google 地图上使用它,我想知道是否有任何方法可以获得相同的结果并在 Android 上使用暗模式 Google 地图.

However I haven't been able to use it on Google Maps and wanted to know if there was anyway to get the same result and use Dark Mode Google Maps on Android.

感谢您的帮助

推荐答案

在 xamarin.android 中创建一个原始文件夹,并添加包含主题的 json 文件,然后编写此代码及其工作.NativeMap.SetMapStyle(MapStyleOptions.LoadRawResourceStyle(this.Context, Resource.Raw.map_style_night));

Make a Raw Folder in xamarin.android and add you json file that have you Theme then write this code and its work. NativeMap.SetMapStyle(MapStyleOptions.LoadRawResourceStyle(this.Context, Resource.Raw.map_style_night));

这篇关于如何在 Xamarin.Forms.Maps 中使用暗模式 Google 地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆