废话不多说,直接上代码
//动态效果
public void convertText(final TextView textView, final int convertTextId) {
final Animation scaleIn = AnimationUtils.loadAnimation(this,
R.anim.text_scale_in);
Animation scaleOut = AnimationUtils.loadAnimation(this,
R.anim.text_scale_out);
scaleOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
textView.setText(convertTextId);
textView.startAnimation(scaleIn);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
textView.startAnimation(scaleOut);
}
text_scale_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="500"
android:fromXScale="0"
android:fromYScale="0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
text_scale_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="150"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0"
android:toYScale="0" />
</set>