Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView loadDataWithBaseUrl - weird issue in android 4.0.3

In my project there are two WebViews and I am switching these WebViews alternatively to get a smooth animation while loading my url. When I am using Webview.loadUrl() method, it works fine in all devices. But when I am using the same code with loadDataWithBaseUrl() then its not working in 4.0.3 but it's working fine in 2.2, 2.3, 4.0.4, 4.1 devices.

Is this a bug jumping from WebKit? I tried so many ways to get this done but no way out. I am really frustrated and messed-up with this.

It will be so helpful if someone could show me a right way to get this done.

like image 575
Jackson Chengalai Avatar asked Jan 22 '13 13:01

Jackson Chengalai


People also ask

Why won’t some HTML content load in my WebView?

We spent some time trying to figure out why some html content would not load in our app’s WebView. We found trivial html can be loaded into a WebView using the loadData (String, String, String) method. Rendering complex pages with Javascript is a problem.

How to use WebView loaddata() with non latin1 encodings?

To use WebView.loadData () with non latin1 encodings you have to encode html content. Previous example was not correctly working in Android 4+, so I have modified it to look as follows:

What does loaddata() actually do?

As I understand it, loadData () simply generates a data: URL with the data provide it. If the value of the encoding parameter is 'base64', then the data must be encoded as base64.


1 Answers

You can try to add these property with webview-

mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

and can use animation because its working well for me like-

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
  <translate 

      android:interpolator="@android:anim/cycle_interpolator"
      android:fromXDelta="100%p" android:toXDelta="0" android:duration="1000"/>
</set>
like image 184
Dinesh Avatar answered Oct 10 '22 22:10

Dinesh