TextView Animation or Alpha animation (FadeIn , FadeOut) in ANDROID
Jumat, 19 April 2013
0
komentar
An Alpha Animation is animation that controls the alpha level of an object, i.e. fading it in and out. In Android, you can apply that fading effect to almost anything, from simple text, to images, buttons, check boxes, etc…
This can be done both from xml and from java class.
Here I will explain a simple way to give a FadeIn and FadeOut for a textview on button click..
This can be done both from xml and from java class.
Here I will explain a simple way to give a FadeIn and FadeOut for a textview on button click..
public class Textviewanimation extends Activity {
Animation fadeIn,fadeOut;
TextView tv;
Button startanimation;
Boolean fadeflag=true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_textviewanimation);
tv=(TextView) findViewById(R.id.textview);
startanimation=(Button) findViewById(R.id.button1);
fadeIn = new AlphaAnimation(0.0f , 1.0f ) ;
fadeIn.setDuration(1200);
fadeIn.setFillAfter(true);
fadeOut = new AlphaAnimation(1.0f , 0.0f);
fadeOut.setDuration(1200);
fadeOut.setFillAfter(true);
startanimation.setText("Start fadeIn");
startanimation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
if(fadeflag)
{
startanimation.setText("Start fadeOut");
tv.setText("This is an animated textview");
tv.startAnimation(fadeIn);
fadeflag=false;
}
else
{
startanimation.setText("Start fadeIn");
tv.setText("This is an animated textview");
tv.startAnimation(fadeOut);
fadeflag=true;
} } });
}
}
and res/anim/fadeout
Then in java
same way call the other
Animation animationFadeIn = AnimationUtils.loadAnimation(this,R.anim.fadein);
tv.startAnimation(animationFadeIn);
see more
Falling animation ..TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: TextView Animation or Alpha animation (FadeIn , FadeOut) in ANDROID
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidpopuler.blogspot.com/2013/04/textview-animation-or-alpha-animation.html. Terima kasih sudah singgah membaca artikel ini.Ditulis oleh Unknown
Rating Blog 5 dari 5
0 komentar:
Posting Komentar