This is my Code i have done both SWIPING and ZOOM IN and ZOOM OUT 
functions. But both doesnt worked in my app inside webview.

My problem is, If i do comment this line, then Swiping works fine !

webSettings.setBuiltInZoomControls(true);

If i don't comment this above line, then Zoom In and Out is working fine 
but swiping does not works here !


public class ZoomInandOutActivity extends Activity {
  private GestureDetector gestureDetector;
  WebView webviewSwiping;
  WebSettings webSettings;
  String data1 = "<html>"  +  "<body><h1>Hello, Android Aspect!</h1></body>"  + 
 "</html>";
  String data2 = "<html>"  +  "<body><h1>Hellos, Android Aspectz!</h1></body>"  
+  "</html>";
/* The Minimum distance a finger must travel in order to register a swipe event 
*/
    private static final int SWIPE_MIN_DISTANCE = 120;
    private static final int SWIPE_MAX_OFF_PATH = 250;
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;
/** Called when the activity is first created. */@Overridepublic void 
onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    webviewSwiping=new WebView(this);
    webSettings =webviewSwiping.getSettings();
    webviewSwiping.setOnTouchListener(new View.OnTouchListener() {@Override
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });
 webSettings.setJavaScriptEnabled(true);
 webSettings.setBuiltInZoomControls(true); // used for Zooming and scrolling
/* Gesture Detection */
    gestureDetector=new GestureDetector(this, new MyGestureDetector());
    setContentView(webviewSwiping);}class  MyGestureDetector extends 
SimpleOnGestureListener{
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, 
float velocityY) {
         try {
             if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) 
                 return false;
          /* right to left swipe*/
             if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && 
Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                 webviewSwiping.loadData(data1, "text/html", "UTF-8"); 
                 Toast.makeText(ZoomInandOutActivity.this, "Left Swipe", 
Toast.LENGTH_LONG).show();
             }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && 
Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
                 webviewSwiping.loadData(data2, "text/html", "UTF-8"); 
                 Toast.makeText(ZoomInandOutActivity.this, "Right Swipe", 
Toast.LENGTH_LONG).show();}
         } catch (Exception e) {
             // nothing
         }
        return false;
    }}


What i wanted is, If i do left or right swipe at that time zoom in and out 
should not work. If i do Zoom in and out those webview contents at that time 
left and right swiping must not work.

Like, When i do enable Swiping, Zooming must be disabled and when i do Zooming 
enabled at this time Swiping event must be disabled !

Moreover, I have a doubt that can i be able to achieve this both events inside 
webview by using setBuiltInZoom controls in Android 2.2 ?

How shall i achieve this both events in webview??

Please kindly anyone help me !

Any help or suggestions would be highly appreciated, thanks !

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to