Android Animation hide and reveal text

Asked

Viewed 314 times

-1

Good afternoon guys I am basic android dev,I need the name of the application that appears in my splash,keep appearing and disappearing as it happens in the initial splash of facebook,In this interval I need the name of the app to be excited so it doesn’t look like the screen is stopped,

  • Just to complement I want the text to be flashing very smooth,I think now I can explain

  • Supplement by editing your question.. Remember that we will help you answer questions and not do the job for you. What you have tried to do?

  • Put a sample of your code we can help you better

  • Have you looked here? https://developer.android.com/training/animation/index.html

  • It would be nice if you put in the code you have now, so it doesn’t look like "do such a thing for me".

1 answer

4

You can use the abstract class Animation to carry out the animation, and the class AlphaAnimation to smooth the transition. Then just use the method setRepeatMode() as REVERSE and the method setRepeatCount() passing by INFINITE to repeat this animation until you leave the screen. See:

Programmatically:

Animation animation = new AlphaAnimation(1.0f, 0.0f);
// definição do tempo de duração da animação
animation.setDuration(500); 
animation.setRepeatMode(Animation.REVERSE);
animation.setRepeatCount(Animation.INFINITE);

// aqui você coloca seu TextView ou ImageView, ou
// até mesmo outra view, da forma como você quiser
findViewById(R.id.textView).startAnimation(animation);

Using XML:

Or, you can create an XML inside the directory anim

res/anim/fadeinout.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromAlpha="1.0"
    android:toAlpha="0.0"
    android:duration="500"
    android:repeatCount="infinite"
    android:repeatMode="reverse"
    />

In his main, you use the method AnimationUtils.loadAnimation() in this way:

Animation animation = AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.fadeinout);
findViewById(R.id.textView).startAnimation(animation);

As I described above, it will give effect to TextView. If you choose a ImageView, using the same code, the result will be this below:

inserir a descrição da imagem aqui

...about 7 seconds

As you commented: "It’s gonna run for, like, seven seconds", just use the Handler(). Behold:

// a animação deve estar fora do Handler.
new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
       // aqui dentro você insere o código para sair dessa tela
    }
}, 7000); // 7000 milesegundos equivale a 7 segundos.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.