touch - How to reset Layout back to original state after zooming ends -


i have graphview(com.jjoe64.graphview.graphview) inside linear layout , need zoom in , out,i applied default zooming code as,

// activate horizontal zooming , scrolling

graphview1.getviewport().setscalable(true); 

// activate horizontal scrolling

graphview1.getviewport().setscrollable(true); 

// activate horizontal , vertical zooming , scrolling

graphview1.getviewport().setscalabley(true); 

// activate vertical scrolling

graphview1.getviewport().setscrollabley(true); 

but points distorted while zooming in , out.so decided apply zooming effect linear layout contains graphview using scalegesturedetector , gesturedetector,now can zoom in , out horizontal scrolling not possible , need reset layout original state on scaleend or doubletap, please help, posted code below,

gesturedetector = new gesturedetector(this, new gesturelistener());     // animation scalling     mscaledetector = new scalegesturedetector(this, new scalegesturedetector.simpleonscalegesturelistener()     {         @override         public boolean onscalebegin(scalegesturedetector detector) {             log.i(tag, "onscalebegin");             toast.maketext(mainactivity.this,"onscalebegin",toast.length_short).show();             return true;         }          @override         public boolean onscale(scalegesturedetector detector)         {             float scale = 1 - detector.getscalefactor();              float prevscale = mscale;             mscale += scale;              if (mscale < 0.1f) // minimum scale condition:                 mscale = 0.1f;              if (mscale > 10f) // maximum scale condition:                 mscale = 10f;             scaleanimation scaleanimation = new scaleanimation(1f / prevscale, 1f / mscale, 1f / prevscale, 1f / mscale, detector.getfocusx(), detector.getfocusy());             scaleanimation.setduration(0);             scaleanimation.setfillafter(true);              layout =(scrollview) findviewbyid(r.id.scroll);             layout.startanimation(scaleanimation);             layout2 = (horizontalscrollview)findviewbyid(r.id.horizscroll);             layout2.startanimation(scaleanimation);             return true;         }          @override         public void onscaleend(scalegesturedetector detector) {             super.onscaleend(detector);             log.i(tag, "onscaleend");             toast.maketext(mainactivity.this,"onscaleend",toast.length_short).show();         }     }); private class gesturelistener implements gesturedetector.ongesturelistener,gesturedetector.ondoubletaplistener {     @override     public boolean ondown(motionevent motionevent) {         return true;     }      @override     public void onshowpress(motionevent motionevent) {      }      @override     public boolean onsingletapup(motionevent motionevent) {         return false;     }      @override     public boolean onscroll(motionevent motionevent, motionevent motionevent1, float v, float v1) {         return false;     }      @override     public void onlongpress(motionevent motionevent) {      }      @override     public boolean onfling(motionevent motionevent, motionevent motionevent1, float v, float v1) {         return false;     }      @override     public boolean onsingletapconfirmed(motionevent motionevent) {         return false;     }      @override     public boolean ondoubletap(motionevent motionevent) {         return true;     }      @override     public boolean ondoubletapevent(motionevent motionevent) {         return true;     } }  @override public boolean dispatchtouchevent(motionevent event) {     super.dispatchtouchevent(event);     mscaledetector.ontouchevent(event);     gesturedetector.ontouchevent(event);     return gesturedetector.ontouchevent(event); } 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -