Java 一起旋转图像视图和文本视图

Java 一起旋转图像视图和文本视图,java,android,rotation,Java,Android,Rotation,我有一个ImageView和TextView在上面,我想把它们一起旋转。 我看到我对每个视图都有setRotation()方法,我可以同时对两个视图使用它,而不是对每个视图单独使用它吗?将它们放在Framelayout中并旋转Framelayout很简单,我希望这能解决您的问题 旋转包含图像和文本的整个布局。试试这个。希望这对你有帮助 ObjectAnimator anim = ObjectAnimator.ofFloat(view, "y", 100f); arrayListObjectAni

我有一个
ImageView
TextView
在上面,我想把它们一起旋转。
我看到我对每个视图都有
setRotation()
方法,我可以同时对两个视图使用它,而不是对每个视图单独使用它吗?

将它们放在Framelayout中并旋转Framelayout很简单,我希望这能解决您的问题


旋转包含图像和文本的整个布局。

试试这个。希望这对你有帮助

ObjectAnimator anim = ObjectAnimator.ofFloat(view, "y", 100f);
arrayListObjectAnimators.add(anim);

ObjectAnimator anim1 = ObjectAnimator.ofFloat(view, "x", 0f);
arrayListObjectAnimators.add(anim1);

ObjectAnimator[] objectAnimators = arrayListObjectAnimators.toArray(new ObjectAnimator[arrayListObjectAnimators.size()]);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(objectAnimators);
animSetXY.duration(1000);
animSetXY.start();

也许可以将两个视图放入FrameLayout视图中,然后可以操作根视图来调用
setRotation()
方法。

尝试将setRotation()实现到父布局,而不是每个子布局。