• 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Move an image inside an ImageView

 
Greenhorn
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

<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
 
Does this tiny ad smell okay to you?
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic