I want to create a login page (Like facebook android app) where the userid and password EditText fields are hidden. A logo is shown on the page which animates above
1st The facebook image goes up so you have to translate it from current position to top
Here android:fromYDelta is start position and android:toYDelta is end position in percentage i.e -30% and android:duration is in time i.e. 1 second
2nd Now attach a listener to check when animation is done 3rd Now Fade in your login box
here is the code
MinActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button startAnimation =(Button) findViewById(R.id.button1);
final LinearLayout LoginBox = (LinearLayout) findViewById(R.id.LoginBox);
LoginBox.setVisibility(View.GONE);
startAnimation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Animation animTranslate = AnimationUtils.loadAnimation(MainActivity.this, R.anim.translate);
animTranslate.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) { }
@Override
public void onAnimationRepeat(Animation arg0) { }
@Override
public void onAnimationEnd(Animation arg0) {
LoginBox.setVisibility(View.VISIBLE);
Animation animFade = AnimationUtils.loadAnimation(MainActivity.this, R.anim.fade);
LoginBox.startAnimation(animFade);
}
});
ImageView imgLogo = (ImageView) findViewById(R.id.imageView1);
imgLogo.startAnimation(animTranslate);
}
});
}
}
And in the anim folder use these xml's
fade.xml
translate.xml
And the layout activity_main.xml