Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.