PDA

Ver la Versión Completa : problema animaciones


rafaxplayer
07/08/15, 08:36:38
Buenas compañeros tengo un problemilla con unas animaciones...
Resulta que tengo dos texview en los cuales uso una animación para que aparezcan uno de izquierda a derecha y el otro viceversa.
Los anim son estos:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="-50%p"
android:toXDelta="0"
android:duration = "1000"/>
</set>

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p"
android:toXDelta="0"
android:duration = "1000"/>
</set>

y el java que lo mueve este;

public class IntroActivity extends AppCompatActivity {
private TextView textIntro1;
private TextView textIntro2;
private TextView textIntro3;
private final int DURACION_SPLASH = 3000;
override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intro);
textIntro1=(TextView)findViewById(R.id.textIntro1) ;
textIntro2=(TextView)findViewById(R.id.textIntro2) ;
textIntro3=(TextView)findViewById(R.id.textpro);

Animation t1= AnimationUtils.loadAnimation(this,R.anim.anim_dere cha);
Animation t2= AnimationUtils.loadAnimation(this,R.anim.anim_izqu ierda);
Animation t3= AnimationUtils.loadAnimation(this,R.anim.anim_fade out);
textIntro1.startAnimation(t1);
textIntro2.startAnimation(t2);
textIntro3.startAnimation(t3);
new Handler().postDelayed(new Runnable() {
public void run() {

Intent intent = new Intent(IntroActivity.this, Inicio_Activity.class);
startActivity(intent);
finish();
}

;
}, DURACION_SPLASH);
}


Bien el problema es que en una tablet las animaciones corren fluidas y sin ningún problema , y sin embargo en un móvil (un samsung Grand Prime) hacen un parón a medio recorrido , no entiendo el motivo de esto , sera por espacio? o que puede ser?

Vídeo con la animación:
PaNk5hwOAV8

LEAJIM_454
08/08/15, 15:32:13
Hola, yo te recomendaria que uses un objectAnimator, son mucho mejores en mi opinion, que las animaciones antiguas y además si quieres dar soporte a dispositivos 3.0- tienes a Nineoldandroids.

rafaxplayer
09/08/15, 15:03:33
gracias por la respuesta , he usado objectanimator y el resultado a sido el mismo que con animation.
:oh:

LEAJIM_454
11/08/15, 17:59:36
Entonces es problema de tiempos de ejecución, es el caso de mi telefono, un Galaxy ace ( xD ) en este terminal Flappy Bird es algo lento, en cambio en un Xperia es mucho mas rapido o normal, si me equivoco me gustaria invocar a kriogeN o mocelet para corregirme, saludos.

kriogeN
12/08/15, 15:10:53
Usando ObjectAnimator no deberías tener ningún problema, yo he usado ObjectAnimator con NineOldAndroids en dispositivos muy antiguos (tan antiguos que no tenían ni HoneyComb) y las animaciones iban perfectas.

En cambio el sistema antiguo de animaciones (AnimationUtils, etc) es muy muy malo, incluso en dispositivos modernos a veces las animaciones tardan en ejecutarse o van a tirones.

rafaxplayer
14/08/15, 18:21:08
Bueno he probado de todo y el efecto queda igual, se traba...

Aquí os dejo el code con objectanimator haber si veis algo...


textIntro1=(TextView)findViewById(R.id.textIntro1) ;
textIntro2=(TextView)findViewById(R.id.textIntro2) ;
textIntro3=(TextView)findViewById(R.id.textpro);

ObjectAnimator translateX1 = ObjectAnimator.ofFloat(textIntro1, "translationX",-100,0);
ObjectAnimator translateX2 = ObjectAnimator.ofFloat(textIntro2, "translationX",100,0);
final ObjectAnimator fadeout = ObjectAnimator.ofFloat(textIntro3, "Alpha",0.0f,1.0f);
fadeout.setDuration(1000).addListener(new Animator.AnimatorListener() {
override
public void onAnimationStart(Animator animation) {

}

override
public void onAnimationEnd(Animator animation) {
Intent intent = new Intent(IntroActivity.this, Inicio_Activity.class);
startActivity(intent);
finish();
}

override
public void onAnimationCancel(Animator animation) {
Intent intent = new Intent(IntroActivity.this, Inicio_Activity.class);
startActivity(intent);
finish();
}

override
public void onAnimationRepeat(Animator animation) {

}
});
fadeout.setInterpolator(new AccelerateInterpolator());
translateX1.setInterpolator(new LinearInterpolator());
translateX1.setDuration(1000);
translateX2.setInterpolator(new LinearInterpolator());

translateX2.setDuration(1000).addListener(new Animator.AnimatorListener() {
override
public void onAnimationStart(Animator animation) {

}

override
public void onAnimationEnd(Animator animation) {
fadeout.start();
}

override
public void onAnimationCancel(Animator animation) {
Intent intent = new Intent(IntroActivity.this, Inicio_Activity.class);
startActivity(intent);
finish();
}

override
public void onAnimationRepeat(Animator animation) {

}
});
translateX2.start();
translateX1.start();