Paul Hinrichsen

Greenhorn
+ Follow
since May 15, 2020
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Hinrichsen

Good day All

I am using Android Studio 3.6.3

The scenario I need to set up is as follows;

I need a picture inside an ImageView (or something similar). The picture starts in the centre of the ImageView. I need one button which will rotate the ImageView (and thus also rotate the picture inside the ImageView).
A second button which will move the picture inside the ImageView (but NOT the ImageView) along the X line.

The code for the ImageView is

<ImageView
 android:id="@+id/mymap"
 android:layout_width="500dp"
 android:layout_height="300dp"
 android:layout_gravity="center"
 android:background="@drawable/mapsmall"/>

The picture is the item @drawable/mapsmall

I define the ImageView in Java as

imageView = (ImageView) findViewById(R.id.mymap);

The code for the rotate animation is

ObjectAnimator rotateMap = ObjectAnimator.ofFloat(imageView,
               "rotation", 0f, 180f)
               .setDuration(1000);

The code for the moveX is

ObjectAnimator moveX = ObjectAnimator.ofFloat(imageView,
               "translationX", 200f, 500f)
               .setDuration(1000);

Now the rotation works fine and rotates the ImageView.
The MoveX works well and moves the ImageView.

Since both animations target

imageView = (ImageView) findViewById(R.id.mymap);

This may be no surprise.

In the MoveX animation how do I TARGET ONLY the picture which is inside the ImageView and not the whole ImageView? My Animation requires me to move the image inside the imageView (if this is possible)

I am new to AS (that may be obvious from my code).

I have previously coded this animation successfully in both ActionScript3 as wel as in Javascript. I know that Java is a much more powerful code than either. it MUST be possible to do this ?

Any help will be greatly appreciated.

Thanks

Paul
3 years ago