android - Pinch and Zoom imageview -


i have task pinch , zoom imageview, have made app swiping images , working fine; want pinch , zoom imageview on same class ;but not able this.i have gone through various example seems nothing helping in case.below code,or provide me example problem.

imageview.setontouchlistener(new ontouchlistener() {                 @override  public boolean ontouch(view view, motionevent event) {   bitmap = bitmapfactory.decoderesource(context.getresources(), image_id[position]);   bmpwidth = bitmap.getwidth();   bmpheight = bitmap.getheight();   distcurrent = 1;    dist0 = 1;   drawmatrix();   float distx, disty;    switch(event.getaction() & motionevent.action_mask){    case motionevent.action_down:     //a pressed gesture has started, motion contains initial starting location.      touchstate = touch;     break;    case motionevent.action_pointer_up:         //a non-primary pointer has gone up.          touchstate = touch;         break;    case motionevent.action_pointer_down:     //a non-primary pointer has gone down.      touchstate = pinch;      //get distance when second pointer touch     distx = event.getx(0) - event.getx(1);     disty = event.gety(0) - event.gety(1);     dist0 = floatmath.sqrt(distx * distx + disty * disty);      break;    case motionevent.action_move:     //a change has happened during press gesture (between action_down , action_up).      if(touchstate == pinch){            //get current distance      distx = event.getx(0) - event.getx(1);      disty = event.gety(0) - event.gety(1);      distcurrent = floatmath.sqrt(distx * distx + disty * disty);       drawmatrix();     }      break;    case motionevent.action_up:     //a pressed gesture has finished.     touchstate = idle;     break;    }   touchstate = idle;             return true;         }     });      private void drawmatrix(){      float curscale = distcurrent/dist0;      if (curscale < 0.1){       curscale = 0.1f;       }       bitmap resizedbitmap;          int newheight = (int) (bmpheight * curscale);      int newwidth = (int) (bmpwidth * curscale);      system.out.println("new width: "+newwidth+" new heigt: "+newheight);      resizedbitmap = bitmap.createscaledbitmap(bitmap, newwidth, newheight, false);      system.out.println("resized bitmap: "+resizedbitmap);      imageview.setimagebitmap(resizedbitmap);      } 

i have integrate same functionality application.

but know zoomable imageview not possible in android.

i have use following library: https://github.com/sephiroth74/imageviewzoom

try this. may helps you...:)


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -