我的应用程序中有一个 TextView,我希望它从左边缘沿 Y 轴旋转。
使用这段代码,
<rotate
android:fromDegrees="90"
android:toDegrees="0"
android:pivotX="0%"
android:pivotY="0%"
android:duration="2000" />
我可以让它沿左边缘旋转,但它不会沿 Y 轴移动。
但是,当我使用 objectAnimator 时,它会使用其 rotationY 属性沿 Y 轴移动,但是我无法设置值 pivotX 和 pivotY 这使得它沿着中心而不是从左边缘旋转。
如何同时实现这两件事?
请帮帮我!!
提前致谢。
最佳答案
检查这个card flip animation来自安卓。 基本上你定义了 4 个动画并设置动画顺序
getFragmentManager()
.beginTransaction()
.setCustomAnimations(
R.animator.card_flip_right_in, R.animator.card_flip_right_out,
R.animator.card_flip_left_in, R.animator.card_flip_left_out)
.replace(R.id.container, new CardBackFragment())
.addToBackStack(null)
.commit();
您可能想要更改角度和“valueFrom”、“valueTo”属性以满足您的需要。
关于Android - 沿 Y 轴旋转对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22140448/