W / WebCore的(2733):第一个布局后无法获得viewWidth [英] W/webcore(2733): Can't get the viewWidth after the first layout

查看:159
本文介绍了W / WebCore的(2733):第一个布局后无法获得viewWidth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个Web视图彼此相邻,用于单独纺纱的显示。我得到这个错误somtimes,这会导致窗口渲染的问题。

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.

我的继承人XML ...

heres my xml...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">
   <LinearLayout 

    android:orientation="horizontal" 
    android:layout_height="300dp"
    android:layout_width="match_parent"
    android:gravity="center">

        <WebView
            android:id="@+id/measure_view" 
            android:background="#77000000"
            android:layout_height="match_parent" 
            android:layout_width="160dp"
            android:focusable="true"/>

        <WebView
            android:id="@+id/input_view" 
            android:background="#77000000"
            android:layout_height="match_parent" 
            android:layout_width="160dp"
            android:focusable="true"/>
        <WebView
            android:id="@+id/output_view" 
            android:background="#77000000"
            android:layout_height="match_parent" 
            android:layout_width="160dp"
            android:focusable="true"/>


    </LinearLayout>

有什么想法?

谢谢,纳撒尼尔。

推荐答案

对于任何人谁都有这样的问题:

For anyone who has this problem:

从我发现有一些线程会被创建的网页视图时,和某些变量 - 宽度例如,正在跨线程引用。这是引用code不完美,因为有时数据是在渲染时不可用。

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.

看看这个:

<一个href=\"http://www.java2s.com/Open-Source/Android/android-core/platform-frameworks-base/android/webkit/WebViewCore.java.htm\"相对=nofollow> code

和CTRL-F的错误的文本无法获取viewWidth......,你就会明白我在说什么。

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

在这里一个有趣的延续,我用多个网页视图 - 这可能加重了这个问题。另一个有趣的方面是,它没有在我的code web视图总是第一个有装进去的内容,虽然它并不总是失败。

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.

我的解决办法一直让事情失败的第一次,然后重新呈现失败web的图。

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

希望这有助于。

纳撒尼尔。

这篇关于W / WebCore的(2733):第一个布局后无法获得viewWidth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆