Cómo agregar animación a una vista de texto en android

Tengo un TextView y estoy tratando de añadir un desvanecimiento en la animación. Mi código está regresando null y no entiendo por qué.

Aquí está mi implementación

Este es el fade_in.xml

  <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" android:duration="1000" android:fromAlpha="0.0" android:interpolator="@android:anim/accelerate_interpolator" android:toAlpha="1.0"/> 

Y aquí es cómo im usarlo en la actividad correspondiente

  tv= (TextView)findViewById(R.id.textView); //-- the below line is returning null animation = AnimationUtils.loadAnimation(this,R.anim.fade_in); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { tv.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { Intent it = new Intent(SplashActivity.this, MainActivity.class); startActivity(it); } @Override public void onAnimationRepeat(Animation animation) { } }); tv.startAnimation(animation); 

Ejemplos de Android TextView Annimation

XML

 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="2.0" android:toYScale="2.0" android:duration="3000"></scale> </set> 

Código

 private void RunAnimation() { Animation a = AnimationUtils.loadAnimation(this, R.anim.scale); a.reset(); TextView tv = (TextView) findViewById(R.id.firstTextView); tv.clearAnimation(); tv.startAnimation(a); } 

Para más :

http://chiuki.github.io/advanced-android-textview/#/5

http://www.hascode.com/2010/09/playing-around-with-the-android-animation-framework/

¿Es correcto su id de texto? Primero comprueba si estás recibiendo tu id de texto correctamente en tu aplicación.

Puede cargar animaciones de la clase AnimationUtils en Android y establecerla en una vista de texto en android.

 textview.startAnimation(AnimationUtils.loadAnimation(c, android.R.anim.fade_in)); 

Y puede detener la animación utilizando,

 textview.clearAnimation(); 

Necesitas setAnimation en tu TextView

Ejemplo:

 tv.setAnimation( animation ); 

Utilizar Animator / AnimatorSet Animation es código heredado

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.