我希望能够通过编程移动ImageView(改变其在x和y轴上的位置)。 在main.xml中的代码:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.app.name.GameView
android:id="@+id/game"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
在 Activity 中的代码:
ImageView image = (ImageView) findViewById(R.id.image);
image.setBackgroundResource(R.anim.my_anim);
image.scrollTo (10,10);
/* Creating animation... */
mAnim = (AnimationDrawable) image.getBackground();
/* etc. */
ScrollBy()和ScrollTo()命令不起作用。可能不需要移动图片,但是mAnim?
注:此文内容涉及IT技术相关内容,如需进一步了解,请自行搜索相关资料。