Hi I am using WebView
in android application to show content. I am showing content as well as images.
I used webView.getSettings().setLoadsImagesAutomatically(false);
this code to block loading of images. My problem is images are not loading but space of the image is showing white space. Can anyone suggest me how to remove that white space from WebView
.
Asked
Active
Viewed 1,197 times
0

Saeed Masoumi
- 8,746
- 7
- 57
- 76

user2591169
- 1
- 2
-
Hi thanks for your reply. I used loadData("myData", "text/html", null);. MyData is coming from WordPress server, it contains images also. I don't want to load images so , I used webView.getSettings().setLoadsImagesAutomatically(false); code to stop loading images. It works fine but my problem is images are not loading but in image place it is showing blank white space. Can u please suggest me to remove the white space also. – user2591169 Jan 07 '15 at 06:35
1 Answers
0
webview1.loadUrl("javascript:window.document.getElementsByClassName('elementToHide')[0].style.display='none';")
Where elementToHide is to class name of the element you choose to hide

Stéphane GROSSMANN
- 369
- 2
- 5
- 14
-
Hi thanks for your reply. I am not using loadUrl(); method to load data. I used loadData("myData", "text/html", null);. MyData is coming from WordPress server, it contains images also. I don't want to load images so , I used webView.getSettings().setLoadsImagesAutomatically(false); code to stop loading images. It works fine but my problem is images are not loading but in image place it is showing blank white space. Can u please suggest me to remove the white space also. – user2591169 Jan 07 '15 at 06:35
-
1OH sorry, misunderstood your pb. So u should first remove from "myData" what u don't wanna show, and after that do your loadData wit-h the new HTML. Something like replacing every img tag with blank. – Stéphane GROSSMANN Jan 07 '15 at 08:44
-
1Hi thank you. It solved my image white space problem. I am getting one more problem. I am using ViewPager to view posts in my application. WebView contains useless Horizontal scrolling. It disturbs ViewPage to view posts. Can u please suggest me how to remove the scrolling. – user2591169 Jan 07 '15 at 09:19
-
Sure, try webView.setVerticalScrollBarEnabled(false); Thanks to accept solution – Stéphane GROSSMANN Jan 07 '15 at 09:22
-
It does't solve my problem. I am getting one more problem please solve this also. I am getting this exception when I am loading my post "Uncaught TypeError: Object # – user2591169 Jan 07 '15 at 09:33
-
it depends on your the app target. See http://stackoverflow.com/questions/20695973/android-webview-uncaught-typeerror-object-object-object-has-no-method-chan – Stéphane GROSSMANN Jan 07 '15 at 09:39
-
I am using my tagetSdkVersion=21. I used @JavascriptInterface this annotation in my fragment also but I did't solve that exception. – user2591169 Jan 07 '15 at 09:45
-
Try http://stackoverflow.com/questions/5355805/uncaught-typeerror-object-object-has-no-method-movingboxes it seems to be the same problem. – Stéphane GROSSMANN Jan 07 '15 at 09:52
-
Hi I am trying to add jQuery api to "MyData" but it is again showing same exception. – user2591169 Jan 07 '15 at 10:29