Xamarin.Forms 中 WebView 的透明背景(便携式) [英] Transparent background of WebView in Xamarin.Forms (Portable)

查看:41
本文介绍了Xamarin.Forms 中 WebView 的透明背景(便携式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 Xamarin.Forms(便携式)中播放 GIF 图像,但现在我需要删除 WebView 的背景.所以,它看起来会很不错.

I am able to play GIF image in Xamarin.Forms (Portable) but now I need to remove the background of the WebView. So, that it will look pretty good.

这里是 Xamarin.Forms(便携式)中 GIF 播放器的链接

Here is the link for the GIF player in Xamarin.Forms (Portable)

推荐答案

正如 Yuri S 已经提到的,您不应该使用 WebView.对于显示 GIF 动画这样简单的任务来说,这是一种矫枉过正.相反,您应该查看 James 的 GifImageView 控件黑山.它使用适用于 iOS 和 Android 的自定义渲染器使用 GIF 功能扩展了默认图像控件.

As Yuri S already mentioned, you shouldn't be using the WebView. It's an overkill for such a simple task as showing a GIF animation. Instead, you should look at the GifImageView control by James Montenegro. It extends the default Image control with GIF capabilities using custom renderers for iOS and Android.

如果你真的想使用 WebView,你需要为每个平台编写自己的自定义渲染器,以实现真正的透明.

If you really want to use the WebView, you need to write your own custom renderer for each platform to achieve true transparency.

iOS:Opaque 属性设置为 false,并确保背景颜色为 UIColor.Clear.Xamarin.Forms WebView 的默认实现已经设置了背景颜色,因此您只需要处理 Opaque 属性.

iOS: Set the Opaque property to false and make sure that the background color is UIColor.Clear. The default implementation of Xamarin.Forms WebView already has the background color set, so you only need to take care of the Opaque property.

Android:将WebView的BackgroundColor属性设置为0x00000000

Android: Set the BackgroundColorproperty of the WebView to 0x00000000

PCL: 确保 HTML 页面的正文具有透明背景.否则它将是白色的,并且底层 WebView 的透明度设置无关紧要.<body style="background-color: transparent;">

PCL: Make sure that the body of your HTML page has a transparent background. Otherwise it will be white and the transparency setting of your underlying WebView doesn't matter. <body style="background-color: transparent;">

这篇关于Xamarin.Forms 中 WebView 的透明背景(便携式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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