开发者

WebView, Splash Screen and performance

I've got WebView within an Activity that loads content from the network. When the WebView starts loading I launch another activity to act as a Splash Screen that I hide when the WebView is done loading.

I found out when testing that the same web page takes longer to load when I add a splash screen than when I don't. So I assume there's a network thread whose priority drops when the activity containing the WebView goes to the background. How do I control that thread to keep the WebView fast?

I found the setRenderPriority method of the WebSettings class, I'm not sure what开发者_运维技巧 it does and I don't know what is the "Render thread" it talks about. I tried :

getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH); 

but it didn't have any effect on the loading time.

Thanks to anyone who can help me out.


I'm not directly answering your question, but rather suggesting an alternative... starting another activity to simply provide a splash screen could be rather expensive. Instead, you might consider extending the layout that contains your WebView to place a RelativeLayout at the WebView's level, and make your WebView a child of that layout. Additionally, you can place an ImageView (or whatever you need for your splash) within the same RelativeLayout, and you can set its visibility to invisible when you don't want it displayed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜