简体   繁体   中英

Rotate together a ImageView an TextView

I have an ImageView and TextView over it , I want to rotate them together. I saw that I have setRotation() method for each view, can I use it to both views together and not use it separately on each one of them?

Try this Demo for Rotate complete view.

Rotate whole layout which contains Image & Text.

操作简单,将它们放置在Framelayout中并旋转framelayout,我希望这可以解决您的问题

Try this. Hope this helps u.

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()方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM