[英]Detect rotation on Android WebView
I'm searching for a way to detect the repaint of the WebView in Android to have the correct value of inner DOM element. 我正在寻找一种方法来检测Android中WebView的重绘以具有内部DOM元素的正确值。 I need this because I use an Javascript Interface to place a view over the webview. 我需要这样做,因为我使用Javascript界面在Webview上放置了一个视图。
View.onlayoutChange didn't do the job because it's sending before html element are repositionned (for responsiveness eg) View.onlayoutChange没有完成这项工作,因为它是在重新定位html元素之前发送的(例如,用于响应)
EDIT 编辑
The only whay I've found is to store a protected int mOrientation;
我发现的唯一方法是存储protected int mOrientation;
on the onLayoutChange I check if the orientation has changed, return if not or save the current orientation mOrientation = getContext().getResources().getConfiguration().orientation;
在onLayoutChange上,我检查方向是否已更改,如果未更改,则返回,或保存当前方向mOrientation = getContext().getResources().getConfiguration().orientation;
Moreover, the size of WebView inner DOM element has some delay ro be changed on rotation so I have delayed my code of 200ms so the DOM element are dimensionate correctly 此外,WebView内部DOM元素的大小在旋转时会有所更改,因此我延迟了200ms的代码,因此DOM元素的尺寸正确
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// your code
}
}, 200);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.