本文整理汇总了C#中WebView.SetLayerType方法的典型用法代码示例。如果您正苦于以下问题:C# WebView.SetLayerType方法的具体用法?C# WebView.SetLayerType怎么用?C# WebView.SetLayerType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebView
的用法示例。
在下文中一共展示了WebView.SetLayerType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InjectHeader
/**
* Have to be called from WebView.WebViewClient.onPageFinished
* ex : mWebView.setWebViewClient(new WebViewClient() { onPageFinished(WebView view, String url) { [HERE] }});
* Inject a header to a webview : add a margin-top="**dpx"
* Had to have a transparent background with a placeholder on top
* So inject js for placeholder and setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); for transparency
* TODO : inject JavaScript for Pre-Lolipop with loadUrl("js:...")
*
* @param webView
* @param withAnimation if true, disapear with a fadein
*/
public static void InjectHeader(WebView webView, bool withAnimation) {
if (webView != null) {
MaterialViewPagerAnimator animator = GetAnimator(webView.Context);
if (animator != null) {
WebSettings webSettings = webView.Settings;
#pragma warning disable 618
webSettings.SetRenderPriority(WebSettings.RenderPriority.High);
#pragma warning restore 618
webSettings.CacheMode = CacheModes.NoCache;
webSettings.JavaScriptEnabled = true;
webSettings.DomStorageEnabled = true;
if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) {
//transparent background
webView.SetLayerType(LayerType.Software, null);
}
{ //inject margin top
int marginTop = animator.GetHeaderHeight() + 10;
string js = string.Format("document.body.style.marginTop= \"{0}px\"", marginTop);
WebViewLoadJs(webView, js);
}
{
string js = "document.body.style.backround-color= white";
WebViewLoadJs(webView,js);
}
if (withAnimation)
webView.PostDelayed(() => {
webView.Visibility = ViewStates.Visible;
ObjectAnimator.OfFloat(webView, "alpha", 0, 1).Start();
}, 400);
}
}
}