I have seen in Android mobile. When i click photo gallery, one image is opened (Fade in) and after I clicked disappeared (Fade out).
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.
How could I do this programmatically in Android?
In what way can I fix this problem? What mistake have I done here?
My code is:
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);
}
}
} );
} }
Then in Main.xml :
<Button
android:id="@+id/Click"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/fade" />
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#AAA"
android:src="@drawable/fade"/>