0

i am using webiview and i override onTouchEvent than built-in zoom control is not working.

    wv.setOnTouchListener(new OnTouchListener()
    {

        public boolean onTouch(View arg0, MotionEvent arg1) 
        {

            if(arg1.getAction()==MotionEvent.ACTION_DOWN)
            {
                x_down = (int) arg1.getX();
                y_down = (int) arg1.getY();

            Log.v("log", "x pos is "+x_down +"y pos is "+y_down);

            }

            else if(arg1.getAction()==MotionEvent.ACTION_UP)
            {
                x_up = (int) arg1.getX();
                y_up = (int) arg1.getY();

            Log.v("log", "x pos is "+x_up +"y pos is "+y_up);


            if((x_down-x_up)>30)
            {
                wv.loadData("<img src=\"myurl_1\">", "text/html", null);
            }
            else if((x_up-x_down)>30)
            {
                 wv.loadData("<img src=\"myurl_2\">", "text/html", null);
            }

            }
            return true;
        }
    });

Thanks in advance...

Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75

2 Answers2

1

You are returning always true from the onTouch method, which means that you are the only one responsible for handling touch events..
you should return true only in the cases you want, and return super.onTouch in the other cases..

Nermeen
  • 15,883
  • 5
  • 59
  • 72
0
       webView.getSettings().setBuiltInZoomControls(true);

add this code to your webview i hope it works

Venkatesh S
  • 5,466
  • 1
  • 25
  • 30