title: How to use fade in and fade out effect with an image using Transition, android
body: <p>I have seen in Android mobile. When i click photo gallery, one image is opened (Fade in) and after I clicked disappeared (Fade out). </p>
  
  <p>Same, I have done in my app. I have pasted one image in Drawable. And applied Fade in and Fade out conditions. But I have not seen any images than sky blue color background. That is view.</p>
  
  <p>How could I do this programmatically in Android?</p>
  
  <p>In what way can I fix this problem? What mistake have I done here?</p>
  
  <p>My code is:</p>
  
  <pre><code>btn=(Button)findViewById(R.id.Click);
     viewToAnimate=(View)findViewById(R.id.view1);
     btn.setOnClickListener(new View.OnClickListener() {
  
      @Override
      public void onClick(View v) {
  
  
          if(viewToAnimate.getVisibility()==View.VISIBLE)
          {
              boolean toRight = false;
              Context c = null;
              //Animation out=AnimationUtils.makeOutAnimation(this,true);
              Animation out=AnimationUtils.makeOutAnimation(c, toRight);
              viewToAnimate.startAnimation(out);
               viewToAnimate.setVisibility(View.INVISIBLE);
  
          } else {
            int id = 0;
          Context c = null;
          //  Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
             Animation in=AnimationUtils.loadAnimation(c, id);
  
              viewToAnimate.startAnimation(in);
              viewToAnimate.setVisibility(View.VISIBLE);
          }
      }
  } );
  
  
  
  } }
  </code></pre>
  
  <p>Then in Main.xml :</p>
  
  <pre><code> &lt;Button
      android:id="@+id/Click"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Button" /&gt;
  
  &lt;ImageView
      android:id="@+id/imageView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/fade" /&gt;
  
  
  &lt;View
      android:id="@+id/view1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#AAA" 
      android:src="@drawable/fade"/&gt;
  </code></pre>