title: How to toggle flip Imageview horizontally in android
body: <p>I have an Imageview and I want to flip picture horizontally whenever user click on the Button named "Flip Picture" . and when User click this button second time it should return to orignal state in other words flip back. </p>
  
  <p>So it should repeat this behavior. I found this useful code to flip the image view with out using external library , but do not know how to flip back:</p>
  
  <p>Here is the Code :</p>
  
  <pre><code> public Bitmap flipImage(Bitmap src, int type) {
      // create new matrix for transformation
      Matrix matrix = new Matrix();
      // if vertical
      if(type == FLIP_VERTICAL) {
          // y = y * -1
          matrix.preScale(1.0f, -1.0f);
      }
      // if horizonal
      else if(type == FLIP_HORIZONTAL) {
          // x = x * -1
  
  
          // unknown type
      } else {
          return null;
      }
  
      // return transformed image
      return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
  }
  </code></pre>
  
  <p>and here is how I am trying to apply it on my Image view named FlipImage</p>
  
  <pre><code>Flipimage.setImageBitmap(flipImage(BitmapFactory.decodeResource(getResources(), R.drawable.doom01),2));
  </code></pre>