[英]android tween animation: how does coordinates works in translate?
I'm learning Tween Animation now, so I made a really simple animation looks like 我现在正在学习补间动画,所以我制作了一个非常简单的动画
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:duration="5000"
android:fillAfter="true"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0%p"/>
</set>
I want the ImageView to move from right edge of the screen to the left. 我希望ImageView从屏幕的右边缘移到左侧。 The ImageView is in a fragment on the bottom of the screen,
ImageView在屏幕底部的一个片段中,
public class BottomFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_fragment, container, false);
ImageView back = (ImageView)view.findViewById(R.id.bottomback);
Animation move = AnimationUtils.loadAnimation(getActivity(), R.anim.move);
back.startAnimation(move);
return view;
}
}
I thought fromXDelta="100%p"
will put the left top corner of the image at the right edge, and toXDelta="0%p"
will put the left top corner of the image at the left edge. 我以为
fromXDelta="100%p"
会将图像的左上角放在右边缘,而toXDelta="0%p"
会将图像的左上角放在左边缘。 But the image seems to move from far away from the edge into the screen and stop at the middle of the screen. 但是图像似乎从远离边缘的位置移动到屏幕中,并停在屏幕中间。 And it seems like the position is the centre of the image instead of the left top corner.
位置似乎是图像的中心,而不是左上角。 I'm confused.
我糊涂了。 How does coordinate system in Tween Animation works?
Tween Animation中的坐标系如何工作? How should I make it start at the edge of the screen/fragment?
我应该如何使其从屏幕/片段的边缘开始?
Well, now it seems like: 好吧,现在看起来像:
fromXDelta=100%
or 100%p
. fromXDelta=100%
或100%p
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.