Android webview,Android viewpager中的缩放问题

Android webview,Android viewpager中的缩放问题,android,webview,Android,Webview,我试图在webview中捏缩“放大视图”页面,它工作正常,但问题是在“视图”页面中,某些设备在缩放过程中并没有调整字体。它被大幅削减。在我的视图页面中,总共有三个webview。那么这可能吗?怎么做 if (position == 2) { RelativeLayout rltvWebView = (RelativeLayout) inflater.inflate( R.layout.htmlcontent, null);

我试图在webview中捏缩“放大视图”页面,它工作正常,但问题是在“视图”页面中,某些设备在缩放过程中并没有调整字体。它被大幅削减。在我的视图页面中,总共有三个webview。那么这可能吗?怎么做

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&#37;\">"
                    + 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&#37;\">"
                    + 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&#37; 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;
        } 
if(位置==2){
RelativeLayout rltvWebView=(RelativeLayout)充气器。充气(
R.layout.htmlcontent,空);
wv=(WebView)rltvWebView.findviewbyd(R.id.WebView);
data=“”
+ ""
+ ""
+ ""
+DeviceInspirationInfo.getDITitle().toString()
+“
” +DeviceInspirationInfo.getDIDesc().toString() +“




”; /* *wv.getSettings().getDefaultZoom(); *wv.getSettings().SetBuilTinZoomControl(true); */ wv.loadDataWithBaseURL(“file:///android_asset/“、数据、, “文本/html”、“UTF-8”、空); wv.setBackgroundColor(透明色); wv.setOnTouchListener(visTouch); ((ViewPager)集合).addView(rltvWebView,0); 返回rltvWebView; }否则如果(位置==3){ RelativeLayout rltvWebView=(RelativeLayout)充气器。充气( R.layout.htmlcontent,空); wv1=(WebView)rltvWebView.findviewbyd(R.id.WebView); 数据1=“” + "" + "" + "" + "" +gemsInfo.getGemsAuthor() + " : " +gemsInfo.getGemsTitle() +“
” +gemsInfo.getGemsDesc() + "" +“




”; wv1.loadDataWithBaseURL(“file:///android_asset/“,数据1, “文本/html”、“UTF-8”、空); wv1.setBackgroundColor(颜色.透明); wv1.setOnTouchListener(visTouch); ((ViewPager)集合).addView(rltvWebView,0); 返回rltvWebView; }否则如果(位置==4){ .pagerdisable=true; RelativeLayout rltvWebView=(RelativeLayout)充气器。充气( R.layout.htmlcontent,空); wv2=(WebView)rltvWebView.findviewbyd(R.id.WebView); 数据2=“” + "" + "" + "" + "" + "" +prernaInfo.getPPTitle() +“
” +prernaInfo.getPPDesc() +“




”; wv2.loadDataWithBaseURL(“file:///android_asset/“,数据2, “文本/html”、“UTF-8”、空); wv2.setBackgroundColor(颜色.透明); wv2.setOnTouchListener(visTouch); ((ViewPager)集合).addView(rltvWebView,0); 返回rltvWebView; }
ontouch侦听器:

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;
    }
};
public OnTouchListener visTouch=new View.OnTouchListener(){
@凌驾
公共布尔onTouch(视图v,运动事件){
手势检测器。onTouchEvent(事件);
if(event.getPointerCount()>1){
如果(!(v==rltvList)){
如果(v==wv){
wv.getSettings().setDefaultZoom(
WebSettings.动物密度.中等);
wv.getSettings().getDefaultZoom();
wv.getSettings().SetBuilTinZoomControl(true);
View zwv=wv.getZoomControl();
//wv.设定初始刻度(10);
zwv.setVisibility(View.GONE);
wv.setOnTouchListener(visTouch);
Log.v(“Log_标记”,“v==rltvList,如果(v==wv)”);
}否则如果(v==wv1){
wv.invalidate();
wv1.getSettings().setDefaultZoom(
WebSettings.动物密度.中等);
wv1.getSettings().getDefaultZoom();
wv1.getSettings().SetBuilTinZoomControl(真);
Log.v(“Log_tag”,“(v==rltvList)else if(v==wv1)”;
}如果(v==wv2),则为else{
wv1.invalidate();
wv2.getSettings().setDefaultZoom(
WebSettings.动物密度.中等);
wv2.getSettings().getDefaultZoom();
wv2.getSettings().SetBuilTinZoomControl(true);
Log.v(“Log_tag”,“(v==rltvList)else if(v==wv2)”;
}
如果(event.getAction()==MotionEvent.ACTION\u指针\u 2\u向上
||event.getAction()==MotionEvent.ACTION\u指针\u 1\u向上){
如果(v==wv){
wv.getSettings().SetBuilTinZoomControl(false);
Log.i(“wv”,“+event.getPointerCount());
View zwv=wv.getZoomControl();
zwv.setVisibility(View.GONE);
wv.invalidate();
wv.setOnTouchListener(visTouch);
Log.v(“日志标签”,
“event.getAction()==MotionEvent.ACTION_指针_2_UP if(v==wv)”;
}否则如果(v==wv1){
wv.invalidate();
wv1.getSettings().setDefaultZoom(
WebSettings.动物密度.中等);
wv1.getSettings().getDefaultZoom();
wv1.getSettings().SetBuilTinZoomControl(false);
Log.v(“日志标签”,
“event.getAction()==MotionEvent.ACTION_指针_2_UP else if(v==wv1)”;
}如果(v==wv2),则为else{