在没有画布的android中移动图像

在没有画布的android中移动图像,android,Android,如何在不使用画布的情况下在AndroidView中移动ImageView??我想翻译一个像动画一样的图像,但画布让我困惑:S也许这个能帮你 TranslateAnimation ta = new TranslateAnimation(fromX, toX, fromY, toY); ta.setDuration(300); ta.setAnimationListener(new AnimationListener() { public void onAni

如何在不使用画布的情况下在AndroidView中移动ImageView??我想翻译一个像动画一样的图像,但画布让我困惑:S

也许这个能帮你

    TranslateAnimation ta = new TranslateAnimation(fromX, toX, fromY, toY);
    ta.setDuration(300);
    ta.setAnimationListener(new AnimationListener() {
        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {

        }
    });
    yourView.startAnimation(ta);

根据需要设置值,并在onAnimationEnd上设置视图布局参数。从具有视图当前值的值设置,并在给定值后根据新的x和y值设置视图

哇,谢谢。。但问题是图像在动画制作后返回到其原始位置。您应该在animationonAnimationEnd的和处设置images LayoutParams。例如:您的图像布局重力是右侧的,您将其向左移动,设置toX=0,然后在onAnimationEnd将重力更改为左侧我是android新手,所以,您可以给我看一些设置布局参数的代码吗??