我的应用程序使用透明背景的WebView
,其中元素的某些样式属性由JavaScript修改。在webview内容被JavaScript修改后,Android WebView未刷新
问题:WebView
未根据修改的属性进行刷新。当WebView
重新绘制(例如,由于用户方向更改)时,WebView
已正确更新。 我在Android 3.2(在三星GT)上重现了这个问题,但在Android 2.1和4.3上都很好。
重现问题的示例代码:
很明显,当第一个图像被点击时,它应该消失,点击第二个图标应该移动它。如果WebView
的背景颜色更改为不透明,或者如果我删除显示在WebView
下方的图像,所有工作都会正常...
HTML由Web视图加载。 :
<!DOCTYPE html>
<html>
<body >
<img style="position:absolute;left:0px" onclick="this.style.display='none';"
src="http://flv.justad.tv/gallery/assets/trickplay/justad/tp-pause.png" />
<img style="position:absolute;left:200px" onclick="this.style.top='200px';"
src="http://flv.justad.tv/gallery/assets/trickplay/justad/tp-ff.png" />
</body>
</html>
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/display_background" />
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/WebviewContainer">
</RelativeLayout>
</RelativeLayout>
应用Activity
:水龙头前
public class TestImageMoveActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
RelativeLayout webviewContainer =
(RelativeLayout)findViewById(R.id.WebviewContainer);
WebView web = new WebView(this);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
web.setLayoutParams(
new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
web.setBackgroundColor(Color.TRANSPARENT);
webviewContainer.addView(web);
web.loadUrl("http://192.168.1.12/myWeb/localTmp/testImageMove.html");
}
}
屏幕截图:
Screen shot before tap
Screen shot after tap on both images
您的屏幕截图链接已损坏(权限被拒绝)。 – 2012-02-29 13:58:25
对不起,链接应该现在工作 – hailrok 2012-02-29 14:25:34
不需要道歉,只是说你注意到它。 :) – 2012-02-29 14:26:20