title: How to see image in full screen with zoom in / zoom out when touch on image
body: <p>I have the following imagedetails.xml layout:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;LinearLayout
          android:id="@+id/inLay"
          android:layout_width="wrap_content"
          android:layout_height="150dp"
          android:orientation="horizontal" &gt;
  
          &lt;HorizontalScrollView
              android:id="@+id/hsv"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentTop="true"
              android:fillViewport="true"
              android:measureAllChildren="false"
              android:scrollbars="none" &gt;
  
              &lt;LinearLayout
                  android:id="@+id/innerLay"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal" &gt;
  
                  &lt;LinearLayout
                      android:id="@+id/controlled_medication"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="vertical" &gt;
  
                      &lt;RelativeLayout
                          android:layout_width="fill_parent"
                          android:layout_height="match_parent" &gt;
  
                          &lt;ImageView
                              android:id="@+id/image1"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content" /&gt;
                      &lt;/RelativeLayout&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;LinearLayout
                      android:id="@+id/as_needed_medication"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="vertical" &gt;
  
                      &lt;RelativeLayout
                          android:layout_width="fill_parent"
                          android:layout_height="match_parent"
                          android:orientation="horizontal" &gt;
  
                          &lt;ImageView
                              android:id="@+id/image2"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content" /&gt;
                      &lt;/RelativeLayout&gt;
                  &lt;/LinearLayout&gt;
              &lt;/LinearLayout&gt;
          &lt;/HorizontalScrollView&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and for this xml file I have writeen following code:</p>
  
  <pre><code>public class ImageDetails extends Activity {
  
      LinearLayout asthmaActionPlan, controlledMedication, asNeededMedication,
              rescueMedication, yourSymtoms, yourTriggers, wheezeRate, peakFlow;
      LayoutParams params;
      LinearLayout next, prev;
      int viewWidth;
      GestureDetector gestureDetector = null;
      HorizontalScrollView horizontalScrollView;
      ArrayList&lt;LinearLayout&gt; layouts;
      int parentLeft, parentRight;
      int mWidth;
      int currPosition, prevPosition;
  
  
      ImageView image1, image2;
  
  
      String pid;
  
  
      private ProgressDialog pDialog;
  
  
      JSONParser jsonParser = new JSONParser();
  
  
      private static final String url_detials = "http://www.example.com/details.php";
  
  
      private static final String TAG_SUCCESS = "success";
      private static final String TAG_PRODUCT = "product";
      private static final String TAG_PID = "id";
      Private static final String TAG_IMAGE1 = "image1";
      private static final String TAG_IMAGE2 = "image2";
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.productdetails);
  
  
          image1 = (ImageView) findViewById(R.id.image1);
          image2 = (ImageView) findViewById(R.id.image2);
  
          Intent i = getIntent();
  
  
          pid = i.getStringExtra(TAG_PID);
  
  
          StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                  .permitAll().build();
          StrictMode.setThreadPolicy(policy);
  
          horizontalScrollView = (HorizontalScrollView) findViewById(R.id.hsv);
          gestureDetector = new GestureDetector(new MyGestureDetector());
  
          controlledMedication = (LinearLayout) findViewById(R.id.controlled_medication);
          asNeededMedication = (LinearLayout) findViewById(R.id.as_needed_medication);
  
          Display display = getWindowManager().getDefaultDisplay();
          mWidth = display.getWidth(); // deprecated
          viewWidth = mWidth;
          layouts = new ArrayList&lt;LinearLayout&gt;();
          params = new LayoutParams(viewWidth, LayoutParams.WRAP_CONTENT);
          controlledMedication.setLayoutParams(params);
          asNeededMedication.setLayoutParams(params);
  
          layouts.add(controlledMedication);
          layouts.add(asNeededMedication);
  
          horizontalScrollView.setOnTouchListener(new OnTouchListener() {
              public boolean onTouch(View v, MotionEvent event) {
                  if (gestureDetector.onTouchEvent(event)) {
                      return true;
                  }
                  return false;
              }
          });
  
          new GetDetails().execute();
  
  
  
      }
  
  
  
      class MyGestureDetector extends SimpleOnGestureListener {
          @Override
          public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                  float velocityY) {
              if (e1.getX() &lt; e2.getX()) {
                  currPosition = getVisibleViews("left");
              } else {
                  currPosition = getVisibleViews("right");
              }
  
              horizontalScrollView.smoothScrollTo(layouts.get(currPosition)
                      .getLeft(), 0);
              return true;
          }
      }
  
      public int getVisibleViews(String direction) {
          Rect hitRect = new Rect();
          int position = 0;
          int rightCounter = 0;
          for (int i = 0; i &lt; layouts.size(); i++) {
              if (layouts.get(i).getLocalVisibleRect(hitRect)) {
                  if (direction.equals("left")) {
                      position = i;
                      break;
                  } else if (direction.equals("right")) {
                      rightCounter++;
                      position = i;
                      if (rightCounter == 2)
                          break;
                  }
              }
          }
          return position;
      }
  
      class GetDetails extends AsyncTask&lt;String, String, String&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(ImageDetails.this);
              pDialog.setMessage("Loading Please wait...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(false);
              // pDialog.show();
          }
  
          @Override
          protected String doInBackground(String... arg) {
  
  
              runOnUiThread(new Runnable() {
                  public void run() {
  
                      int success;
                      try {
  
                          List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
                          params.add(new BasicNameValuePair("id", pid));
  
  
                          JSONObject json = jsonParser.makeHttpRequest(
                                  url_detials, "GET", params);
  
  
  
                          success = json.getInt(TAG_SUCCESS);
  
                          if (success == 1) {
  
                              JSONArray productObj = json
                                      .getJSONArray(TAG_PRODUCT); 
  
  
                              JSONObject product = productObj.getJSONObject(0);
  
                              Bitmap bitmap = null;
                              Bitmap bitmap2 = null;
                              try {
                                  // Download Image from URL
                                  InputStream input = new java.net.URL(
                                          product.getString(TAG_IMAGE1))
                                          .openStream();
                                  // Decode Bitmap
                                  bitmap = BitmapFactory.decodeStream(input);
                                  image1.setImageBitmap(bitmap);
  
                                  // Download Image from URL
                                  InputStream input2 = new java.net.URL(
                                          product.getString(TAG_IMAGE2))
                                          .openStream();
                                  // Decode Bitmap
                                  bitmap2 = BitmapFactory.decodeStream(input2);
                                  image2.setImageBitmap(bitmap2);
                              } catch (Exception e) {
                                  e.printStackTrace();
                              }
  
  
  
                          } else {
  
                          }
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  }
              });
              return null;
          }
      }
  
      protected void onPostExecute(String file_url) {
          // dismiss the dialog once got all details
          pDialog.dismiss();
  
      }
  }
  </code></pre>
  
  <p>Now it will give me output in horizontal view where I can change image through gesture touch.</p>
  
  <p>Now When I am select any image than it will open in full screen with zoomin/zoomout option .</p>
  
  <p>I have try following method:</p>
  
  <pre><code>    image1.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              image1.buildDrawingCache();
              Bitmap bitmap = image1.getDrawingCache();
  
              Intent intent = new Intent(getApplicationContext(),
                      Imagesview.class);
              intent.putExtra("BitmapImage", bitmap);
          }
      });
  </code></pre>
  
  <p>I am sending image to other activity but it is not open new activity.</p>
  
  <p>I am getting following error log:</p>
  
  <pre><code>FATAL EXCEPTION: main
  Process: com.novumlogic.ideal, PID: 18636
    java.lang.NullPointerException
      at com.novumlogic.ideal.ProductDetails$MyGestureDetector.onFling(ProductDetails.java:213)
      at android.view.GestureDetector.onTouchEvent(GestureDetector.java:610)
      at com.novumlogic.ideal.ProductDetails$1.onTouch(ProductDetails.java:133)
      at android.view.View.dispatchTouchEvent(View.java:7772)
      at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2316)
      at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2013)
      at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
      at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027)
      at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
      at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027)
      at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
      at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027)
      at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
      at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027)
      at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322)
      at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027)
      at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2145)
      at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1577)
      at android.app.Activity.dispatchTouchEvent(Activity.java:2508)
      at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2093)
      at android.view.View.dispatchPointerEvent(View.java:7973)
      at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4384)
      at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4255)
      at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3801)
      at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3851)
      at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3820)
      at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3927)
      at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3828)
      at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3984)
      at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3801)
      at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3851)
      at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3820)
      at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3828)
      at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3801)
      at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6116)
      at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6096)
      at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6050)
      at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6246)
      at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
      at android.os.MessageQueue.nativePollOnce(Native Method)
      at android.os.MessageQueue.next(MessageQueue.java:138)
      at android.os.Looper.loop(Looper.java:150)
      at android.app.ActivityThread.main(ActivityThread.java:5333)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>So,how can I show image on full screen with zoom in/out option?</p>