如何翻译动漫作品:安卓 [英] How a Translate Animation works: Android

查看:147
本文介绍了如何翻译动漫作品:安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图移动 RelativeLayout的使用 TranslateAnimation 。 code我已经进行同一写的:

I'm trying to move a RelativeLayout using TranslateAnimation. Code I have written for performing the same is:

translateAnimation = new TranslateAnimation(0, 0, heightOfRootView-excuseContainer.getHeight(), currentYPoint);
translateAnimation.setRepeatMode(0);
translateAnimation.setDuration(500);
translateAnimation.setFillAfter(true);
excuseContainer.startAnimation(translateAnimation);

我试图从特定视图的当前y位置开始动画 (我不需要改变的视图x位置) 但动画盯着从第一Y点每次。我怎么能执行从目前来看y位置这个动作来看所需的位置。

I'm trying to start animation from current y position of particular view (I do not need to change x position of view) But animation is staring every time from its first y point. How can I perform this action from current y position of view to desired position of view.

下面 heightOfRootView 为全屏幕高度, excuseContainer 的是,鉴于这是我想要移动与动画 currentYPoint 是最后一个y的点 excuseContainer

Here heightOfRootView stands for height of full screen, excuseContainer is that view which I want to move with animation and currentYPoint is last y point of excuseContainer.

编辑: 我有没有翻译的动画教程可用。我搜索了它,但我din't发现。

I there any Translate animation tutorial available. I searched for it but I din't found..

感谢您的支持。

推荐答案

正在使用 TranslateAnimation 构造函数的第三个参数是增量值,这样的出发点是像计算:

The 3rd parameter of the TranslateAnimation constructor you are using is a delta value, so the starting point is calculated like:

currentYPos + startingDeltaY

既然你似乎是在传递一个值是指事物在屏幕上的位置,此增量值将是不正确的。

Since you seem to be passing in a Y value that refers to the location of something on the screen, this delta value won't be correct.

请尝试使用此构造:

公共TranslateAnimation(INT fromXType,浮fromXValue,INT toXType,浮toXValue,INT fromYType,浮fromYValue,INT toYType,浮动toYValue)

public TranslateAnimation (int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)

这样的:

new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, heightOfRootView-excuseContainer.getHeight(), Animation.ABSOLUTE, currentYPoint);

这篇关于如何翻译动漫作品:安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆