Can a panorama viewer effect be done with TranslateAnimation? - android

I made an Image Viewer with TouchImageView that I forked to my needs. In particular, you can fit the image vertically in the screen, and then drag the image from left to right. This is nice for a panorama, for example, that you can drag and see it all.
Now I want to do exactly this with panoramas without touching the screen, that is, an automatic constant drag.
I tried to implement this through a TranslateAnimation, but failed miserably: TranslateAnimation "moves the view", and the image is slowly being replaced with a growing black strip instead of more image.
Of course I can move the image 1 pixel, wait 1/100s, move again and so on, but there should be an easier way (and consuming less resources).
Is there some option in TranslateAnimation that allows to do this? How would you do it?
Thanks!!

Related

Android Studio - What are possible options to overlay two images and make only the right or left half of each image visible?

I am trying to have two images overlayed in two imageViews and when i start a swiping gesture the upper image is cropped vertically at the starting point of my touch gesture and the cropping line follows my gesture on screen to the left or right. When I move my finger to the right the cropping line should follow it and reveal more of the upper image for example, until I lift my finger from the screen. The crop should stay there then.
The goal ist to be able to compare two images with a swiping gesture.
I hope what I am trying to achieve is halfway understandable and I would be happy about any kind of input regarding that topic ;)
Thank you in advance

100 animated pics on an Android screen

Imagine emptying a pouch having 100 stamps on a small area. That would be the starting point for my screen. I should be able to scale individual stamps in and out, animate them on a swiping gesture, overlay them and animate them so they all come towards the place of a former stamp that just got swiped out of screen, filling that space in. Plus zooming and panning over the entire screen.
I have made canvas level zooming, panning, and drawing by hand, but I feel this is going to benefit a lot from some kind of library. What should I be looking for ? Math libraries, physics, game engines ?
I don't suppose making these into ImageViews and all together into a ViewGroup and trying to make it work from there would be a good idea.
Thanks

How can I animate an ImageView after I applied transformations on it?

I am trying to implement the zoom and drag features for an image viewer. So far I created the custom ImageView and implemented the actual features for pinch zoom and drag using the transformation matrix of the view. Now I want to animate the transition from the last position to a legal one (the user can drag the image where he/she wants but when it is released it should bounce back). If I just make modifications on the transformation matrix it works but, as I said, I want animations.
My problem is that if the image is out of the screen and I animate the view back the image is cut and remains truncated even after the animation is finished. I should mention that the image is set using the setImageUri method.
Does anyone have any idea on this one?

Mimicking the "rubber band" effect from iOS in the Gallery on Android

I've got a Gallery class showing a bunch of images in an Android app, but since only one image is ever displayed at a time, it is difficult for the user to see when they have reached the first or last image in the gallery. Is there a way to mimic iOS' "rubber band" effect, so that the user sees a bit of empty space when dragging the last image, and they release it, the image snaps back to the center of the view. Is this possible to do?
Look into easing equations
http://www.gizma.com/easing/
when releasing the screen while been dragging the last image, you can use them to smoothly animate the image back to the center of the screen.
As for the effect while dragging the last image, use a multiplication factor on the position of the image so the more your finger reaches the side of the screen, the less the image will follow its movement.

View Animation (Resizing a Ball)

i am trying to do this:
1) user long touches the screen,
2) a circle/ball pops up (centered around the user's finger) and grows in size as long as the user is touching the screen
3) once the user lets go of the finger, the ball (now in its final size) will bounce around.
i think i have the bouncing around figure out from the DivideAndConquer example, but i am not sure how to animate the ball's growth. i looked at various view flipper examples such as this:
http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html
but it seems like view flipper is best for swapping two static pictures. i wasn't able to find a good view animator example other than the flippers. also, i would prefer to use images as opposed to just a circle. can someone point me in the right direction?
thanks.
Here are two simple tutorials to help you get started with drawing basic animations including touch input: balls bouncing randomly around the screen and basic drag and drop.
In brief: You're right, ViewFlipper is really not suited for this. You want to draw on a Canvas by making your own custom View. This is the basic framework for 2D graphics. Canvases let you draw image files, solid colors and other things to the screen, while applying transformations ot them at the same time. Handling the user input (i.e. the finger on the screen) is done via the onTouchEvent(...) method, which lets you do something when the finger touches the screen, moves on the screen or lifts off. Have a play with those two tutorials, they should give you the basics.
If you're using a bitmap on a canvas to draw it
http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint)
Use a scale matrix, the identity multiplied by the scalar of the size you want the image to be.

Categories

Resources