Transparent background of WebView in Xamarin.Forms (Portable)

*爱你&永不变心* 提交于 2020-08-11 07:33:29

问题


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.

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


回答1:


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.

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

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: Set the BackgroundColorproperty of the WebView to 0x00000000

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;">



来源:https://stackoverflow.com/questions/42137722/transparent-background-of-webview-in-xamarin-forms-portable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!