我正在android.and我的代码在webview上工作
private final Handler handler = new Handler(this);
private WebView wv;
wv.getSettings().setBuiltInZoomControls(true);
wv = (WebView) v.findViewById(R.id.webView1);
String data = "<html><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />"
+ "<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; min-scale=1.0; max-scale=3.0; \" />"
+ "<body>"
+ "<div style=\"text-align:center;width:100%\">"
+ "Murti"
+ "</div> <br/><div>"
+ "Touch and hold one of the customizable icons, then drag it to Remove. Touch ... The controls appear under your finger, and you can slide to a control and select it. ... Find apps with the biggest Wi-Fi data usage, then reduce their sync"
+ "</div><br/><br/><br/><br/></body></html>";
wv.loadDataWithBaseURL("file:///android_asset/", data,
"text/html", "UTF-8", null);
wv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.webView1
&& event.getAction() == MotionEvent.ACTION_DOWN) {
handler.sendEmptyMessageDelayed(1, 500);
}
return false;
}
});
public boolean handleMessage(Message msg) {
if (msg.what == 1) {
Toast.makeText(MainActivity.this, "WebView clicked",
Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
isuue 是,当我在 webview 上捏缩放而不是 zoomingcontroll 可见并且在那之后 ontouch 不工作。没有缩放 ontouch 工作正常。