Created
March 8, 2014 01:18
-
-
Save xalexchen/9423589 to your computer and use it in GitHub Desktop.
crossfade two view
From http://developer.android.com/training/animation/crossfade.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private View mContentView; | |
private View mLoadingView; | |
private int mShortAnimationDuration; | |
... | |
private void crossfade() { | |
// Set the content view to 0% opacity but visible, so that it is visible | |
// (but fully transparent) during the animation. | |
mContentView.setAlpha(0f); | |
mContentView.setVisibility(View.VISIBLE); | |
// Animate the content view to 100% opacity, and clear any animation | |
// listener set on the view. | |
mContentView.animate() | |
.alpha(1f) | |
.setDuration(mShortAnimationDuration) | |
.setListener(null); | |
// Animate the loading view to 0% opacity. After the animation ends, | |
// set its visibility to GONE as an optimization step (it won't | |
// participate in layout passes, etc.) | |
mLoadingView.animate() | |
.alpha(0f) | |
.setDuration(mShortAnimationDuration) | |
.setListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
mLoadingView.setVisibility(View.GONE); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment