我试图动画UI元素。我想从中间移到一个EditText和一个按钮在表格下方他们一个HTTP调用的屏幕和显示结果的顶部。这将是巨大的,如果任何人都可以点我在正确的方向,在这一点上,我不知道我阉应该使用Java或XML这一点。Android的UI元素的动画
在此先感谢。
我试图动画UI元素。我想从中间移到一个EditText和一个按钮在表格下方他们一个HTTP调用的屏幕和显示结果的顶部。这将是巨大的,如果任何人都可以点我在正确的方向,在这一点上,我不知道我阉应该使用Java或XML这一点。Android的UI元素的动画
在此先感谢。
用翻译框架,以实现这一目标,该工程为:
TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
所以,你需要写你在y轴方向移动视图代码,如下所示:
mAnimation = new TranslateAnimation(0, 0, 0, 599);
mAnimation.setDuration(10000);
mAnimation.setFillAfter(true);
mAnimation.setRepeatCount(-1);
mAnimation.setRepeatMode(Animation.REVERSE);
view.setAnimation(mAnimation);
这里查看可以是任何东西,TextView的,ImageView的等
接受的答案引起了错误我的代码里面,下面的代码片段几乎等同于接受的答案& WO在不造成错误的情况下,将对象从屏幕上滑下。我需要手势绑键盘也“滑走”,并从TranslateAnimation切换到ObjectAnimator(以下代码第二块)。
final LinearLayout keyPad = (LinearLayout)findViewById(R.id.keyPad);
moveKeyPadUp(keyPad);
private void moveKeyPadUp(LinearLayout keyPad){
Animation animation = new TranslateAnimation(0,0,0,-500);
animation.setDuration(1000);
animation.setFillAfter(true);
keyPad.startAnimation(animation);
}
private void moveKeyPadUpdated(LinearLayout keyPad){
ObjectAnimator mover = ObjectAnimator.ofFloat(keyPad,"translationY",0,-500);
mover.setDuration(300);
mover.start();
}
谢谢,这正是我一直在寻找的。 – Meatje 2012-02-07 09:36:35