Skip to content

Instantly share code, notes, and snippets.

@kyleclegg
Created March 15, 2013 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleclegg/5169005 to your computer and use it in GitHub Desktop.
Save kyleclegg/5169005 to your computer and use it in GitHub Desktop.
Helper methods to show and hide Android layouts
// Helper method to animate the showing of a view
private void showLayout (final LinearLayout theLayout) {
AlphaAnimation fade_in = new AlphaAnimation(0.0f, 1.0f);
fade_in.setDuration(500);
fade_in.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation arg0) {
}
public void onAnimationRepeat(Animation arg0) {
}
public void onAnimationEnd(Animation arg0) {
theLayout.setVisibility(View.VISIBLE);
}
});
theLayout.startAnimation(fade_in);
}
// Helper method to animate the hiding of a view
private void hideLayout (final LinearLayout theLayout) {
AlphaAnimation fade_out = new AlphaAnimation(1.0f, 0.0f);
fade_out.setDuration(500);
fade_out.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation arg0) {
}
public void onAnimationRepeat(Animation arg0) {
}
public void onAnimationEnd(Animation arg0) {
theLayout.setVisibility(View.GONE);
}
});
theLayout.startAnimation(fade_out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment