1

如何用android源代码实现我的想法

我有很多图像,我想一张一张地移动图像,如果图像在目标点上移动,那么其他图像在前面的图像后面移动。

插图

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

image1,image2,image3                           x (point destination move)

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

如果 image3 移动

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
image1,image2                           image3 x

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

如果 image2 移动,则 image3 跟随移动 image2

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
image1                           image2,image3 x

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

等等

如何实现到源代码android

我是新手

谢谢

4

1 回答 1

1

对于移动的物体,在 android 中我们有一个叫做 TranslateAnimation 的概念。这是从左到右移动我的对象的示例片段:

ll = new LinearLayout(this);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ll.setOrientation(LinearLayout.VERTICAL);

tv = new TextView(this);
tv.setText("Animation");

moveLefttoRight = new TranslateAnimation(0, 200, 0, 0);
moveLefttoRight.setDuration(1000);
moveLefttoRight.setFillAfter(true);

button = new Button(this);
button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
button.setText("PressMe");
button.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        tv.startAnimation(moveLefttoRight);
    }

});

ll.addView(tv);
ll.addView(button);
setContentView(ll);

然后,您可以将相同的技巧应用于您的三个图像。

希望这会帮助你..

于 2012-10-12T04:39:02.163 回答