title: How to adjust focus area on touch in camera api android
body: <p>I have a code to focus camera to touch position in the screen. In that left-right touch position focus correctly on touch. but top-bottom touch position not working correctly. can any one help how to resolve this</p>
  
  <pre><code> // Surface view on touch
   @Override
   public boolean onTouchEvent(MotionEvent event) {
       ((CameraActivity) getContext()).touchFocus(event);
       return true;
   }
  
  public void touchFocus(MotionEvent event) {
  
      if (event.getAction() != MotionEvent.ACTION_DOWN) {
          return;
      }
  
      float x = event.getX();
      float y = event.getY();
  
  
      Rect touchRect = new Rect(
              (int) (x - 100),
              (int) (y - 100),
              (int) (x + 100),
              (int) (y + 100));
  
      final Rect targetFocusRect = new Rect(
              touchRect.left * 2000 /mPreview.getWidth()  - 1000,
              ((touchRect.top * 2000) /mPreview.getHeight()) - 1000,
              touchRect.right * 2000 /mPreview.getWidth() - 1000,
              ((touchRect.bottom * 2000) /mPreview.getHeight()) - 1000);        
  
      final List&lt;Camera.Area&gt; focusList = new ArrayList&lt;Camera.Area&gt;();
      Camera.Area focusArea = new Camera.Area(targetFocusRect, 1000);
      focusList.add(focusArea);
  
      Camera.Parameters para = mCamera.getParameters();
      para.setFocusAreas(focusList);
      para.setMeteringAreas(focusList);
      try {
          mCamera.setParameters(para);
          mCamera.autoFocus(mAutoFocusTakePictureCallback);
      } catch (Exception e) {
          AppController.log(TAG, "focusOnTouch : " + e.getLocalizedMessage());
      }
  }
  
  private Camera.AutoFocusCallback mAutoFocusTakePictureCallback = new Camera.AutoFocusCallback() {
      @Override
      public void onAutoFocus(boolean success, Camera camera) {
          if (success) {
              AppController.log(TAG, "Success");
          } else {
              AppController.log(TAG, "Failed");
          }
      }
  };
  </code></pre>