Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to use filesystem folder as baseUrl for the WebView?

$
0
0

Hi,
I have this problem: I want to load an html string that use a css file the I downloaded in the temp path. With iOS I have no problems, but in Android i cannot make it works.

Any ideas?

This is the code:

var temppath = System.IO.Path.GetTempPath();

// This is my function to download the file in the temp folder.
DownloadCssFunction("http://.../demo.css", System.IO.Path.Combine(temppath, "demo.css");

var html_string = "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Hello World</title><link href="demo.css" rel="stylesheet" type="text/css"></head><body><h1>Hello World</h1></body></html>";

var html_source = new HtmlWebViewSource();
html_source.BaseUrl = temppath;

// I also try this but without success
// #if __ANDROID__
// html_source.BaseUrl = "file://" + temppath;
// #endif

html_source.Html = html_source;

WEBView.Source = html_source;

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>