1

我的 main.xml 看起来像这样:

<AbsoluteLayout
   android:id="@+id/AbsoluteLayout01"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   xmlns:android="http://schemas.android.com/apk/res/android"> 

   <ImageView
      android:layout_height="wrap_content"
      android:layout_x="247dip"
      android:layout_width="wrap_content"
      android:layout_y="96dip"
      android:id="@+id/Ball"
      android:src="@drawable/ball"/>

</AbsoluteLayout>

和Java

ball = (ImageView) findViewById(R.id.Ball);

x=247dip, y=96dip如果我想x=100, y=100在我的应用程序运行时将球从另一个方向移动,我该怎么办?

4

2 回答 2

-1

首先将图像的布局高度和宽度设置为 Fillparent 然后使用下面的代码

public void onWindowFocusChanged(boolean hasFocus) {

        ball.scrollTo(10, 20);
    }
于 2010-06-17T13:27:49.613 回答
-2
ball.setLeft(10); //this moves view 10 pixel to left
ball.setLeft(-10); //this moves view 10 pixel to right
ball.setRight(10);//this moves view 10 pixel to right
于 2011-08-23T08:16:52.900 回答