Android Webview Renders Blank/White, View Doesn't Update on CSS Changes or HTML Changes, Animations Are Choppy

Android WebView renders blank/white, view doesn't update on css changes or HTML changes, animations are choppy

I implemented kyle's solution and it solved the problem. Howewer I noticed a huge battery drain on android 4.0.4 when the app was open. Also after the change I had users complaining that the swiftKey keyboard was not working with my app anymore.

Every change in my app are triggered by a user action so I came up with a modified version that only trigger invalidate() after a touchEvent:

    Handler handler = new Handler();
public boolean onTouchEvent (MotionEvent event){
super.onTouchEvent(event);
handler.postDelayed(triggerInvalidate, 60);
handler.postDelayed(triggerInvalidate, 300);
return true;
}

private Runnable triggerInvalidate=new Runnable(){
public void run(){
invalidate();
}
};

Never did any programming with Java so there might be a better solution to do this.

WebView fails to render until touched Android 4.2.2

So I finally found the issue causing the WebView not to render. I am starting and stopping the animation of a drawable inside the WebViewClient of my WebView. This drawable is simply a refresh button that rotates when the page is loading... simple right?

Well in the non-fullscreen mode of the browser, the rotating drawable and the WebView are both children of the same parent, whereas in the fullscreen mode, the drawable becomes a child of the WebView. Somehow, by starting the animation when the page is loading and stopping it when it's done (in fullscreen), the application decides that the rotating drawable is what needs all the drawing power and the WebView never draws. When in fullscreen mode and the drawable becomes a child of the WebView, the WebView then has a higher rendering priority than the drawable and it draws fine.

The moral of the story is... WebViews like to be the highest priority view to be drawn. If there are other views that get greater priority, they won't draw correctly.

I'm no expert on animations, so I need to rethink how I'm animating the drawable now so as to not interrupt the WebView.

Hopefully that made sense. Thanks for reading.

How to render css file from url in to the webview in android

I have faced such type of problem, May be helpful for you,

                webView=(WebView) findViewById(R.id.webView1);

webView.getSettings().setJavaScriptEnabled(true);
StringBuilder sb = new StringBuilder();
sb.append("<HTML><HEAD><LINK href=\"http://test.com/css/test.css\" type=\"text/css\" rel=\"stylesheet\"/></HEAD><body>");
sb.append(attributes.toString());
sb.append("</body></HTML>");
webView.loadDataWithBaseURL(null, sb.toString(), "text/html", "utf-8", null);

Hopefully, it works.

related Links:

and github plugin: https://github.com/NightWhistler/HtmlSpanner

Android WebView renders blank/white, view doesn't update on css changes or HTML changes, animations are choppy

Blank screen on Android 5

The problem was an issue regard to rtl in the new chromium.

The workaround is to add the "rtl" to css on document ready.

Android Webview: Detect when rendering is finished

Finally I got the very detailed for this problem. This explains why it always returns null bitmap.

Every change in my app are triggered by a user action so I came up with a modified version that only trigger invalidate() after a touchEvent

Thank for all your help.

Android WebView renders blank/white, view doesn't update on css changes or HTML changes, animations are choppy

Chart.js not displaying on Android Webview if animation is set to false

I tried this answer on Android WebView renders blank/white and it solved the problem. Basically we tell the WebView to avoid using hardware rendering:

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);


Related Topics



Leave a reply



Submit