0

I am creating a android app in which I want the login screen like facebook.When you open a facebook android app.first "FACEBOOK" text appears in the center of the screen and then it slides up after some time.and userid and password appears with a button.

I want similar kind of animation in my application.

How do i do that. I am using following method

my animate.xml file

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator" >

<translate android:duration="2000"
android:fromYDelta="0"
android:toYDelta="-100%p" /> 
</set>

and the java code.

final Animation animAccelerateDecelerate = AnimationUtils.loadAnimation(this,     R.drawable.animatetext);
    final TextView text = (TextView)findViewById(R.id.Logo);
    text.startAnimation(animAccelerateDecelerate);

but its not working out.. help please thanks

Saurabh Sinha
  • 1,772
  • 4
  • 27
  • 54

3 Answers3

2

you should use android:fillAfter="true" and android:fillEnabled="true" for your animation. android:startOffset="500" adds delay, where 500 is in milliseconds

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/linear_interpolator"
   android:fillEnabled="true"
   android:fillAfter="true"
 >

<translate android:duration="2000"
   android:fromYDelta="0"
   android:toYDelta="-100%p"
   android:startOffset="500"
/> 
</set>
Boris Mocialov
  • 3,439
  • 2
  • 28
  • 55
  • Hi its working fine.but as my activity gets loaded.it starts the animation.I want the animation to start after few seconds.. like in facebook app.and then show the textboxes for username and password and button. – Saurabh Sinha Aug 02 '13 at 10:03
0

Try it like this:

final Animation animLinear = AnimationUtils.loadAnimation(this, R.anim.linear);
final TextView txt = (TextView)findViewById(R.id.Logo);
txt.startAnimation(animLinear);
JavaDM
  • 851
  • 1
  • 6
  • 29
0

I think you should use this:

animAccelerateDecelerate.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {

                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });

Now change your textview's layout params on animation end. so that your textview will get new layout params to be shown on top.

make thread to sleep for some second and then start animation. and on animation end make visible your edittexts for username and passwords.

Hope it Helps!!

Armaan Stranger
  • 3,140
  • 1
  • 14
  • 24
  • hi I used you concept of stopping the thread but the animation is not working out.. animation is not started.. can you please elaborate with some example... – Saurabh Sinha Aug 02 '13 at 10:20
  • animation should start after thread gets end of sleep. not just after when we call thread to sleep. – Armaan Stranger Aug 02 '13 at 11:00