I have a very large html file(around 10k lines of only text). When I use Webview to load this html content, it shows only around few hundreds and remaining space is blank(white space). Can someone help me with this issue? Thank You.
Following is my code:
WebView mWebView;
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("file:///android_asset/test.html");//test.html in assets folder
I also try with webView.setLayerType(WebView.LAYER_TYPE_HARDWARE, null) or webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null) but it does'nt help.
I just found solution for my issue with Webview. The reason Webview can't display whole content of html file because the html is not well constructed, some html tag like <abc#.com> will not be read by Webview. So I convert content to correct html form then it works.
Related
I'm having a problem with Android WebView for my websites. When I open my site on any browser, the CSS style sheet, JavaScript and Images load. But when I open for example through Instagram (which uses WebView), I just have the html, naked.
I precise that all my links are in relative (I have a tag which indicates from where to look for the files).
Here, my base is <base href="http://anthony-e-b.rf.gd/" target="_top">
and my CSS, my images, and my JS refer to this as:
<link rel="stylesheet" href="assets/main.css"> (for the CSS).
Same for my pictures : href="assets/pics/mon_image.jpg".
I do not understand, and although I search the Internet I do not see any solution ...
thank you in advance for your help
Try:
WebView myWebView = findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
Hope it will help!
I was trying to test if it is possible to integrate stripe js in a website and load that site in an android Webview to proceed for payment. I was using this link https://github.com/stripe/elements-examples to load that in Webview like this:
WebView browser = (WebView) findViewById(R.id.webview);
browser.loadUrl("https://stripe.github.io/elements-examples/");
Everything is loading in the Webview except the credit card field is not there. Either it is not visible or it can not be editable. Why is that?
Try to add below code to enable Javascript in your Webview:
WebSettings webSettings = browser.getSettings();
webSettings.setJavaScriptEnabled(true);
I have a html document, I've already tested on the html editor online website (http://htmledit.squarefree.com), it worked fine. However, WebView on android don't show this document, it only show text plain. I have very little experience with html, can anyone help me?
Make sure that your AndroidManifest.xml file includes
<uses-permission android:name="android.permission.INTERNET"/>
just after the
<uses-sdk />
tag. Without this, your app won't be able to access the Internet and therefore webview won't load anything.
HTH
Try -
WebView myWebView = (WebView) findViewById(R.id.webview1);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
This will enable javascript
So, I have a WebView showing page from url:
WebView webView = (WebView) findViewById(R.id.showContentWebView);
String url = "http://edition.cnn.com/2014/02/05/sport/shaun-white-sochi-slopestyle/index.html";
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(url);
And I also have a file "style.css" in my assets folder. How can I display the page in WebView with style.css connected?
I think this is possible only if you somehow process the HMTL content, adding a link to your css file. In this case, please refer to this question.
My webview will works for a site such as Google.com, however, the specific page will not load.
Simply displays subscribe to feedburner (I made this site to reflect a converted news feed)
This specific webpage will display correctly in an Iphone UIWebView, but not for Android.
Some code
WebView rss = (WebView) findViewById(R.id.webviewRSS);
rss.loadUrl("www.newmanu.edu/newmannews");
Check out the source of "www.newmanu.edu/newmannews", you have to activate javascript.
from http://developer.android.com/guide/webapps/webview.html
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
Add http:// or https:// before URL.
Try this.
rss.loadUrl("http://www.newmanu.edu/newmannews");
Or
rss.loadUrl("https://www.newmanu.edu/newmannews");