title: Android ScrollView (scrollable on both Horizontal and Vertical smoothly) on which content addable programatically and zoomable on pinch
body: <p>I need a scrollview where I can add numbers of image and button programatically and on single tap, zoomable by pinch on both horizontal and vertical with smooth scrolling. <a href="http://db.tt/8Wsycjlh" rel="nofollow">Here</a> a video what I need exactly. I have tried with Horizontal scrollview within a ScrollView. I can scroll smoothly. I can add item on single tap. I can't zoom now. Here is the sample code: </p>
  
  <pre><code>   public void setUpNoticeBoard(){
  
      canvasLayout = (FrameLayout) findViewById(R.id.frameLayout);
  
      canvasLayout.removeAllViews();
      FrameLayout.LayoutParams paramsImage = new FrameLayout.LayoutParams(
              LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  
      final ImageView noticeBoard = new ImageView(this);
      noticeBoard.setLayoutParams(paramsImage);
      noticeBoard.setAdjustViewBounds(true);
      noticeBoard.setImageDrawable(getResources().getDrawable(R.drawable.noticeboard));
      noticeBoard.setScaleType(ImageView.ScaleType.CENTER_CROP);
  
      canvasLayout.addView(noticeBoard);
  
      float xx = noticeBoard.getWidth();
      float yy = noticeBoard.getHeight();
  
      System.out.println("noticeBoard Width:" + xx + "And Height:" + yy);
  
      for (int i = 0; i &lt; 50; i++) {
  
          int x= (int)Math.ceil(Math.random()*3000);
          int y= (int)Math.ceil(Math.random()*2000);
  
          FrameLayout.LayoutParams paramsNotice = new FrameLayout.LayoutParams(
                  LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  
          paramsNotice.setMargins(x, y, 0, 0);
  
          final ImageView notice = new ImageView(this);
          notice.setLayoutParams(paramsNotice);
  
          Resources res = getResources();
          String imageName = "pin" + (int)Math.ceil(Math.random()*8);
          int resourceId = res.getIdentifier(imageName, "drawable", getPackageName() );
          notice.setTag(imageName);
          notice.setImageResource(resourceId);
  
          canvasLayout.addView(notice);
      }
  }
  
  @Override
  public boolean onTouchEvent(MotionEvent event) {
  
      float curX, curY;
      newPin.setVisibility(View.INVISIBLE);
      switch (event.getAction()) {
  
          case MotionEvent.ACTION_DOWN:
              mx = event.getX();
              my = event.getY();
              break;
          case MotionEvent.ACTION_MOVE:
              curX = event.getX();
              curY = event.getY();
              vScroll.scrollBy((int) (mx - curX), (int) (my - curY));
              hScroll.scrollBy((int) (mx - curX), (int) (my - curY));
              mx = curX;
              my = curY;
              break;
          case MotionEvent.ACTION_UP:
              curX = event.getX();
              curY = event.getY();
  
              vScroll.scrollBy((int) (mx - curX), (int) (my - curY));
              hScroll.scrollBy((int) (mx - curX), (int) (my - curY));
              break;
      }
  
      return gestureScanner.onTouchEvent(event);
  }
  
  public boolean onSingleTapUp(MotionEvent e) {
  
      int x = (int) e.getX();
      int y = (int) e.getY();
  
      FrameLayout.LayoutParams paramsNewPin = new FrameLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  
      paramsNewPin.setMargins(x + hScroll.getScrollX() - 98, y + vScroll.getScrollY() - 250, 0, 0);
  
      final ImageView newPin = new ImageView(this);
      newPin.setLayoutParams(paramsNewPin);
      newPin.setImageResource(R.drawable.pin5);
  
      canvasLayout.addView(newPin);
  
      return true;
  }
  </code></pre>
  
  <p>Now I need 1 thing Zooming on pinch(Whole content on layout will be zoom)
  Thanks.</p>