W/webcore(2733): Can't get the viewWidth after the first layout

前端 未结 2 1262
时光说笑
时光说笑 2021-01-25 17:25

I have three web Views next to one another, for display of seperate spinners. I get this error somtimes, which causes problems in window rendering.

heres my xml...

相关标签:
2条回答
  • 2021-01-25 18:01

    What happens when it doen't load? do you get an error in the logcat?

    after loading the data, try doing this:

    webView.refreshDrawableState();
    
    0 讨论(0)
  • 2021-01-25 18:13

    For anyone who has this problem:

    From what I've found there's some threading going on when the webviews are created, and certain variables - width for example, are being referenced across threads. This is to quote the code "imperfect" because sometimes the data is unavailable at rendering time.

    Look at this:

    CODE

    and ctrl-f the text of the error "Can't get viewWidth"... and you'll see what I'm talking about.

    An interesting continuation here is that i was using multiple webviews - this may have compounded that problem. Another interesting aspect is that the webview which failed in my code was always the first one to have contents loaded into it, although it did not always fail.

    My solution has been to let things fail the first time, and then re-render the failed web-view.

    Hope this helps.

    Nathaniel.

    0 讨论(0)
提交回复
热议问题