'How can I display html in webview?
I've been using retrofit2 to get a response from the server and get an html String.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
~~~~
I checked that this is normal html. After converting the content to html, open it
However, I tried using loadDataWithBaseURL, loadData, etc. to apply it to the webview, but it does not open, so I ask a question.
my webView setting
hashWebView.settings.apply {
setSupportMultipleWindows(false)
setSupportZoom(false)
javaScriptEnabled = true
javaScriptCanOpenWindowsAutomatically = false
loadWithOverviewMode = true
useWideViewPort = true
builtInZoomControls = false
displayZoomControls = false
layoutAlgorithm = WebSettings.LayoutAlgorithm.SINGLE_COLUMN
cacheMode = WebSettings.LOAD_NO_CACHE
domStorageEnabled = true
databaseEnabled = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
}
}
hashWebView.apply {
webViewClient = WebViewClient()
webChromeClient = WebChromeClient()
//loadData(it,"text/html; charset=utf-8", "UTF-8" )
val encodedHtml = Base64.encodeToString(it.toByteArray(), Base64.NO_PADDING)
loadDataWithBaseURL(null, encodedHtml, "text/html; charset=utf-8", "UTF-8", null)
}
where it is an html string value
How can I open this html string in webview?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
