动画问题
我正在尝试设置一个简单的动画,在屏幕右上角拍摄图像,将其移动到 30% 点,绕圈移动,然后移回边缘。见下图。然而,当前的脚本做了一些奇怪的事情,虽然它最终出现在正确的位置,但在此之前几乎没有什么是正确的。此外,根据 Android 版本和屏幕尺寸,它可能会做更多疯狂的事情。任何帮助将不胜感激。谢谢!
几个要点。我希望开始时的左边缘始终面向运动方向。我想要一个从左向右移动的圆周运动,但如果做不到,我就不会这样做,只要第一部分成立。
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:shareInterpolator="true">
<set>
<translate
android:fromXDelta="0%p" android:toXDelta="0%p"
android:fromYDelta="00%p" android:toYDelta="20%p"
android:duration="001" android:startOffset="0"/>
<translate
android:fromXDelta="0%p" android:toXDelta="-80%p"
android:fromYDelta="00%p" android:toYDelta="0%p"
android:duration="2000" android:startOffset="1"/>
</set>
<set>
<rotate
android:fromDegrees="180"
android:toDegrees="0"
android:pivotY="20%p"
android:duration="1000"
android:startOffset="2000"/>
<translate
android:fromXDelta="0%p" android:toXDelta="70%p"
android:fromYDelta="00%p" android:toYDelta="0%p"
android:duration="100"
android:startOffset="3000"/>
</set>
</set>
I'm trying to set up a simple animation that takes an image on the upper right hand side of the screen, moves it to the 30% point, moves in a circle, and them moves back to the edge. See the figure below. However, the current script does strange things, and while it ends up in the right place, almost nothing seems right before that. Also, depending on the Android version and screen size, it might do even more wild things. Any help would be much appreciated. Thanks!
A couple of key points. I want the left edge at the beginning to always be facing the direction of motion. I would like a circular motion where it moves from left to right, but if it can't be done, I'm not set on it, so long as the first part holds true.
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:shareInterpolator="true">
<set>
<translate
android:fromXDelta="0%p" android:toXDelta="0%p"
android:fromYDelta="00%p" android:toYDelta="20%p"
android:duration="001" android:startOffset="0"/>
<translate
android:fromXDelta="0%p" android:toXDelta="-80%p"
android:fromYDelta="00%p" android:toYDelta="0%p"
android:duration="2000" android:startOffset="1"/>
</set>
<set>
<rotate
android:fromDegrees="180"
android:toDegrees="0"
android:pivotY="20%p"
android:duration="1000"
android:startOffset="2000"/>
<translate
android:fromXDelta="0%p" android:toXDelta="70%p"
android:fromYDelta="00%p" android:toYDelta="0%p"
android:duration="100"
android:startOffset="3000"/>
</set>
</set>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在一个新的 android 项目中使用主 xml 布局中的按钮执行了此操作。它起作用了。所有百分比都是相对于视图位置的父级大小。
I did this in a new android project with a button in the main xml layout. It worked. All percentages are of parent size, relative to the view's position.
我尝试创建您绘图中描述的动画。我将动画分成 2 个文件
left_down.xml
right.xml
这是我在活动中使用的代码
I tried to create the animation described in your drawing. I split the animation in 2 files
left_down.xml
right.xml
And this is the code I used in the activity