AnimationSet animationSet = new AnimationSet(false);
Animation hideAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f);
hideAnimation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
android.R.anim.linear_interpolator));
hideAnimation.setDuration(200);
Animation showAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f);
showAnimation.setStartOffset(200);
showAnimation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
android.R.anim.linear_interpolator));
showAnimation.setDuration(200);
animationSet.addAnimation(hideAnimation);
animationSet.addAnimation(showAnimation);
animationSet.setFillAfter(false);
hideAnimation.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationStart(Animation animation)
{
}
@Override
public void onAnimationRepeat(Animation animation)
{
}
@Override
public void onAnimationEnd(Animation animation)
{
if(tvMenu.getVisibility() == View.VISIBLE)
{
tvMenu.setVisibility(View.GONE);
llEdit.setVisibility(View.VISIBLE);
imgMenuSwitch.setImageResource(R.drawable.icon_chat_pub_menu);
}
else
{
tvMenu.setVisibility(View.VISIBLE);
llEdit.setVisibility(View.GONE);
imgMenuSwitch.setImageResource(R.drawable.icon_chat_pub_keyboard);
}
}
});
llchatBottom.startAnimation(animationSet);
转载于:https://my.oschina.net/bruces/blog/521467