试图将一个按钮到另一点在屏幕上 [英] Trying to Move a Button to Another Point on the Screen

查看:104
本文介绍了试图将一个按钮到另一点在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将3个按键相对于他们的出发点:

I am trying to move 3 buttons relative to their starting points:

在code用于启动动画是:

The code for starting the animation is:

protected void showMoreBtns() {
    Button btn1 = (Button)this.findViewById( R.id.more1btn );
    Button btn2 = (Button)this.findViewById( R.id.more2btn );
    Button btn3 = (Button)this.findViewById( R.id.more3btn );

    Animation showMore = AnimationUtils.loadAnimation( this, R.anim.optionsinup1 );
    btn1.startAnimation( showMore );

    showMore = AnimationUtils.loadAnimation( this, R.anim.optionsinup2 );
    btn2.startAnimation( showMore );

    showMore = AnimationUtils.loadAnimation( this, R.anim.optioninup3 );
    btn3.startAnimation( showMore );
}

和动画的定义是:

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:fromXDelta="0"
        android:fromYDelta="0"
        android:toXDelta="-60"
        android:toYDelta="-30" />
</set>

这三个动画遵循相同的格式,只有机器人:toDelta 的被修改

的问题是动画运行,然而这些按钮返回到它们原来的位置在动画结束。我希望他们留在终点。

The issues is the animation runs, yet the buttons return to their original position at the end of the animation. I would like them to stay at the end point.

推荐答案

showMore.setFillAfter(真正的); 这将被放置在你的java code。 我希望这将是工作。如果你想用你的布局中使用完整的动画后,你将放在onAnimationEnd按钮(动画动画)在那个地方的按钮。

showMore.setFillAfter(true); This will be placed in your java code. I hope it will be work.If you want to use the button after complete animation you will placed onAnimationEnd(Animation animation) in that place the button using your layout.

这篇关于试图将一个按钮到另一点在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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