1箍镜、 4.0后使用
ViewGroup container = (ViewGroup) findViewById(R.id.container);
LayoutTransition transition = new LayoutTransition();
container.setLayoutTransition(transition)
2、 xml 父布局
android:animateLayoutChanges="true"
3、 4.1后子view的動(dòng)畫
LayoutTransition transition = container.getLayoutTransition();
transition.enableTransitionType(LayoutTransition.CHANGING);
4、 給view設(shè)置動(dòng)畫 動(dòng)畫結(jié)束后設(shè)置其可見不可見
if (view.getVisibility() == View.VISIBLE {
TranslateAnimation hideAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f);
hideAnim.setDuration(300);
view.startAnimation(hideAnim);
hideAnim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
} else {
TranslateAnimation showAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
showAnim.setDuration(300);
view.startAnimation(showAnim);
view.setVisibility(View.VISIBLE);
}