• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Move an image inside an ImageView

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


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)

The code for the moveX is

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

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.


    Bookmark Topic Watch Topic
  • New Topic