Android - Zoom in/out from multiple ImageViews - android

Im working on a application that should be able to have diffrent ImageViews applied to a view or layout and zoom in and out from them. Similair to create a chessboard where each square represent a ImageView and then I can zoom out or in from the whole chessboard.
I want to chose a particular ImageView and then add a tween animation to it like a bounce or scaling.
Whats the best approch to do this in Android?

First of all you will need to check which image is focused. To check this you can try :
Image focusedImg = getViewById(R.id.YourMainLayout).findFocus();
Now, once you have the focused image you need to apply tween animations on it. Follow the below mentioned link to apply twwen animation :
http://chengalva.com/dnn_site/Home/tabid/41/EntryId/57/Android-Tween-Animations.aspx
Best,
Shraddha

Related

Using a single view for multiple animations

I have the following animation. Here it show 4 circles simultaneously.
I tried it using multiple views. Like two imageview one on other and applied zoom in and out and translationy animation.
But I want to know If it is possible with single view. If yes then how ?
Thanks in Advance
It is possible if you create an Animation Drawable with different frames inside it. Then you can set this drawable as an image resource and start/stop animation.
All you need is different frames of your animation. You can do that by using some tools available online.
One of which is https://ezgif.com/split
Refer this for animation drawable:
Display an animated PNG image to my layout in android using XML
All the best!

Flip an Imageview with two images back to back

I need to have a set of Image views on a Linear Layout. &
==> onClick of an ImageView, I want to turn the Image to the back(Like Flipping Effect) & show another Image.
==> Again on click of that Image or another Image, I want to apply the same effect for that Image View & the Previous Imageview must come to the default position.
---> I just checked the FLIP ANIMATION in Android. But it is flipping the total view.
So I Just need How to flip an Image view in the same manner, with support from Android v2.2 & up
I think it is quite complicated but it is interesting & need some help how to achieve this as I am just learning the Android(& Coding).
Thanks.!!!
You can use this small library to do that :
https://github.com/castorflex/FlipImageView

How to achieve this folding effect in android?

This is the effect on the ios
Like the effect of paper folded
PaperFold for iOS :https://github.com/honcheng/PaperFold-for-iOS
I suppose you can use scale animations on ImageViews that simulate the paper already folded. The scale effect would be used when you scroll through and expand the entire paper as you continue to scroll through the sets of images. Once you fully scroll through the paper ImageView and the animation is completed, you just kill the animation and have a normal view of a full page paper. Just make a separate folder for animation and inside that folder, create an XML file, select scale and play around with the attributes to test the best suitable effects for your animation.
Hope this helps!
There is a library that helps to implement not accordion-like but another quite interesting folding effect: http://www.youtube.com/watch?v=GzWGhp_NDTg
The explanation & code here http://cases.azoft.com/creating-paper-folding-animation-in-android/
You can use Foldable Layout Lib.
https://github.com/worldline/FoldableLayout

Android. Draw bitmap between two layouts

I want to make application which will have background and some picture with alpha channel in front. Between them i want to draw bitmap/animation.
How can i do it ?
That is easy. You can use FrameLayout as the root layout and set a background to it. Then add two more LinearLayouts which fill the screen. In the first you may add your animated views like ImageView, while in the second you can insert an ImageView or ImageButton with a transparent image in it.
There are many other ways to do this like using a custom view for your animated layer etc. Check my example here: How can I use the animation framework inside the canvas?

How to perform zoom in/out ,rotation together in Android

I want to apply drag,zoom in/out,rotate using multitouch to two images .one
image is placed on the top of the other. after applying these action
Create a image
from above two images after
changes made by applying actions.
I succeed in apply zoom/drag to top image ,created new image from that.
main problem is
1.How to apply action to two images, one image at a time ?
2.How to switch to another image from currently showing image
(which layout I should use)?
3.How user can have a facility to rotate or zoom a image using multitouch ?
What I am missing, Sorry for the list -:)
You need to keep the transformation done to Bitmap1 and apply it again to Bitmap2. for example you can use a Matrix calculated using touch events in order to apply it to the two Bitmaps.
I am not sure to uderstand what you want to do. What i understand is: you've got multiple imageview (that can be composed of 2 images placed on top of another) floating on the layout and you want to select one of them to resize / rotate it.
In order to do that you can simply use the ontouch event of an imageView.
Rotate + zoom with multitouch is not easy in Android, lots of code have to be written in order to make it work nicely. I suggest you to use an existing library. I used this one and it worked like a charm:
https://github.com/lukehutch/android-multitouch-controller
You can see in the sample provided http://code.google.com/p/android-multitouch-controller/source/browse/trunk/demo/MTPhotoSortr/src/org/metalev/multitouch/photosortr/PhotoSortrView.java that you can retreive at any time the new center, angle, and scale ratio of the updated images in mImages(i).getCenterX(), mImages(i).getAngle(), mImages(i).getScaleX(), ...
Using this values you can replicate the transformations (rotation, scaling, translation) on another Bitmap.

Categories

Resources