ビュー ページャーでピンチ ズームを webview しようとしていますが、問題なく動作しますが、ビュー ページャーで一部のデバイスがズーム中にフォントを調整しないという問題があります。鋭く切れています。私のビュー ページャーでは、合計 3 つの webview.so は可能ですか? どうやってするの?
if (position == 2) {
RelativeLayout rltvWebView = (RelativeLayout) inflater.inflate(
R.layout.htmlcontent, null);
wv = (WebView) rltvWebView.findViewById(R.id.webView);
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%\">"
+ devineInspirationInfo.getDITitle().toString()
+ "</div> <br/><div>"
+ devineInspirationInfo.getDIDesc().toString()
+ "</div><br/><br/><br/><br/></body></html>";
/*
* wv.getSettings().getDefaultZoom();
* wv.getSettings().setBuiltInZoomControls(true);
*/
wv.loadDataWithBaseURL("file:///android_asset/", data,
"text/html", "UTF-8", null);
wv.setBackgroundColor(Color.TRANSPARENT);
wv.setOnTouchListener(visTouch);
((ViewPager) collection).addView(rltvWebView, 0);
return rltvWebView;
} else if (position == 3) {
RelativeLayout rltvWebView = (RelativeLayout) inflater.inflate(
R.layout.htmlcontent, null);
wv1 = (WebView) rltvWebView.findViewById(R.id.webView);
data1 = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+ "<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%\">"
+ gemsInfo.getGemsAuthor()
+ " : "
+ gemsInfo.getGemsTitle()
+ "</div> <br/><div>"
+ gemsInfo.getGemsDesc()
+ "</div>"
+ "<br/><br/><br/><br/></body></html>";
wv1.loadDataWithBaseURL("file:///android_asset/", data1,
"text/html", "UTF-8", null);
wv1.setBackgroundColor(Color.TRANSPARENT);
wv1.setOnTouchListener(visTouch);
((ViewPager) collection).addView(rltvWebView, 0);
return rltvWebView;
} else if (position == 4) {
.pagerdisable = true;
RelativeLayout rltvWebView = (RelativeLayout) inflater.inflate(
R.layout.htmlcontent, null);
wv2 = (WebView) rltvWebView.findViewById(R.id.webView);
data2 = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+ "<html><link rel=\"stylesheet\" type=\"text/css\" href=\"gujarati.css\" />"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8 \">"
+ "<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% cursor: pointer;\">"
+ prernaInfo.getPPTitle()
+ "</div> <br/><div style=\"cursor: pointer;\">"
+ prernaInfo.getPPDesc()
+ "</div><br/><br/><br/><br/></body></html>";
wv2.loadDataWithBaseURL("file:///android_asset/", data2,
"text/html", "UTF-8", null);
wv2.setBackgroundColor(Color.TRANSPARENT);
wv2.setOnTouchListener(visTouch);
((ViewPager) collection).addView(rltvWebView, 0);
return rltvWebView;
}
オンタッチ リスナー:
public OnTouchListener visTouch = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
gestureDetector.onTouchEvent(event);
if (event.getPointerCount() > 1) {
if (!(v == rltvList)) {
if (v == wv) {
wv.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv.getSettings().getDefaultZoom();
wv.getSettings().setBuiltInZoomControls(true);
View zwv = wv.getZoomControls();
// wv.setInitialScale(10);
zwv.setVisibility(View.GONE);
wv.setOnTouchListener(visTouch);
Log.v("log_tag", " (v == rltvList) if (v == wv)");
} else if (v == wv1) {
wv.invalidate();
wv1.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv1.getSettings().getDefaultZoom();
wv1.getSettings().setBuiltInZoomControls(true);
Log.v("log_tag", "(v == rltvList) else if (v == wv1)");
} else if (v == wv2) {
wv1.invalidate();
wv2.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv2.getSettings().getDefaultZoom();
wv2.getSettings().setBuiltInZoomControls(true);
Log.v("log_tag", "(v == rltvList) else if (v == wv2)");
}
if (event.getAction() == MotionEvent.ACTION_POINTER_2_UP
|| event.getAction() == MotionEvent.ACTION_POINTER_1_UP) {
if (v == wv) {
wv.getSettings().setBuiltInZoomControls(false);
Log.i("wv", "" + event.getPointerCount());
View zwv = wv.getZoomControls();
zwv.setVisibility(View.GONE);
wv.invalidate();
wv.setOnTouchListener(visTouch);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_POINTER_2_UP if (v == wv)");
} else if (v == wv1) {
wv.invalidate();
wv1.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv1.getSettings().getDefaultZoom();
wv1.getSettings().setBuiltInZoomControls(false);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_POINTER_2_UP else if (v == wv1)");
} else if (v == wv2) {
wv2.invalidate();
wv2.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv2.getSettings().getDefaultZoom();
wv2.getSettings().setBuiltInZoomControls(false);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_POINTER_2_UP else if (v == wv2)");
}
return true;
}
}
return false;
} else {
start.set(event.getX(), event.getY());
if (event.getAction() == MotionEvent.ACTION_DOWN) {
isMove = false;
startpos = event.getY();
startxpos = event.getX();
Log.i("satsang", "Down: " + isMove);
if (v == wv) {
wv.getSettings().setBuiltInZoomControls(false);
wv.invalidate();
wv.setOnTouchListener(visTouch);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_DOWN if(v==wv)");
} else if (v == wv1) {
wv.invalidate();
wv1.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv1.getSettings().getDefaultZoom();
wv1.getSettings().setBuiltInZoomControls(false);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_DOWN else if(v==wv1)");
} else if (v == wv2) {
wv2.invalidate();
wv2.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv2.getSettings().getDefaultZoom();
wv2.getSettings().setBuiltInZoomControls(false);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_DOWN else if(v==wv2)");
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
Log.i("satsang", "Up: " + isMove);
if (v == wv) {
wv.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv.getSettings().getDefaultZoom();
View zwv = wv.getZoomControls();
zwv.setVisibility(View.GONE);
wv.getSettings().setBuiltInZoomControls(false);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_UP if(v==wv)");
} else if (v == wv1) {
wv.invalidate();
wv1.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv1.getSettings().getDefaultZoom();
wv1.getSettings().setBuiltInZoomControls(false);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_UP else if(v==wv1)");
} else if (v == wv2) {
wv2.invalidate();
wv2.getSettings().setDefaultZoom(
WebSettings.ZoomDensity.MEDIUM);
wv2.getSettings().getDefaultZoom();
wv2.getSettings().setBuiltInZoomControls(false);
Log.v("log_tag",
"event.getAction() == MotionEvent.ACTION_UP else if(v==wv2)");
}
int xDiff = (int) Math.abs(event.getX() - start.x);
int yDiff = (int) Math.abs(event.getY() - start.y);
if (xDiff < 6 && yDiff < 6) {
Log.i("satsang", "Padding: " + padding);
if (padding < 0) {
padding *= -1;
Log.v("log_tag", "padding<0");
}
if (padding > 10) {
isMove = true;
Log.v("log_tag", "padding>10");
Log.i("satsang", "Down: " + isMove);
}
// awesomeAdapter.notifyDataSetChanged();
if (!isMove) {
if (footer.getVisibility() == 0) {
Log.v("log_tag", "footer if");
visibility(true);
} else {
visibility(false);
Log.v("log_tag", "footer else");
}
}
return true;
}
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
current = event.getY();
currentx = event.getX();
Log.v("log_tag", "MotionEvent.ACTION_MOVE " + " x "
+ event.getX() + " y " + event.getY());
padding = startpos - current;
paddingx = startxpos - currentx;
if (paddingx < 0) {
paddingx = -paddingx;
}
Log.v("log_tag", "padding " + paddingx + " width "
+ width + " height " + height);
}
}
return false;
}
};