I want to programmatically move ImageView (change its position in the axes x and y). Code in 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>
Code in 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. */
Commands ScrollBy() and ScrollTo() don’t work. May don’t need to move image, but mAnim?
You should be using the ImageView.setX(float) and ImageView.setY(float) functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With