且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的 - 只有在父视图播放动画

更新时间:2022-12-26 20:07:03

这是通过应用反转到子视图(TextView中):

It is possible by applying reverse rotation to child view (TextView):

@Override
public void onClick(final View view) {

    final RotateAnimation rotate = new RotateAnimation(view.getRotation(),
            view.getRotation() - 360.0f, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(300);
    rotate.setFillEnabled(true);
    rotate.setFillAfter(true);
    view.startAnimation(rotate);

    final TextView textView = (TextView)view.findViewById(textViewID);
    final RotateAnimation reverseRotate = new RotateAnimation(view.getRotation(),
            360.0f - view.getRotation(), RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseRotate.setDuration(300);
    reverseRotate.setFillEnabled(true);
    reverseRotate.setFillAfter(true);
    textView.startAnimation(reverseRotate);
}