Android image animation - android

I've been doing the following for the last three days without any success.
Suppose I have one image. I have set that image invisible in my XML layout. Now I want to make it visible through animation. Suppose translate animation.
Suppose there is point A and point B. On point B I have already set the image invisible. From point A I want a translate animation effect. And when it completes, the image B becomes visible.
Please help me.

try using ViewFlipper (or ViewAnimator) setting your ImageView as children and defining animation effect for transition

Related

Alpha Animation acts weird after imageview is moved on touch event in Android

I'm able to successfully make alpha animation work on click of a button. However my imageview can be moved through touch. So when i move my imageview and when i click the fade button it just does not animate it will disappear and appear again.
Also If the imageview is overlapping the original position , it will animate only half of the image(which is overlappint) . It's acting weird not sure why.
I use SetX and SetY to set image's new location.
Can anyone help me out what's the problem?
I figured things out. Instead of positioning the imageview using setX and setY, use Layoutparams to set the imageview. It will work. I used it and it worked completely fine.

Android: Update ImageView Background while Behind other ImageView

I'm building an app where I want to swipe images as though they were photos on a stack. In other words, if I swipe the top image I want it to animate moving in the direction of the swipe and have the next image underneath it visible the whole time. To accomplish this, I'm using a FrameLayout and two ImageView containers. I'm just alternating which one is on top. Meanwhile, as soon as a swipe occurs, the next image is loaded into the ImageView at the back using setBackground(drawable). My problem is that the ImageView at the back doesn't update it's image until I call bringToFront() on it, which means that as the top ImageView is animating, the image underneath is incorrect until the animation completes, at which point it abruptly changes to the correct image. I've tried calling invalidate() on the rear ImageView after setBackground(drawable) but this doesn't work. Anyone have any ideas on how I can get the image to update while it's behind?
UPDATE: Turns out I'm just not very on it today. I was updating the wrong ImageView and because the image loading was being done off the network, there was just enough lag to make me think it was happening after the animation completed.
Sounds to me like you wanna do something like an Image Slider.
There are great libraries existing for this purpose, this one for example:
https://github.com/daimajia/AndroidImageSlider
If you don't wanna use this, here are some tips:
Images on ImageViews are set with setImageDrawable(Drawable)
When your animation starts, set the new Image to your ImageView behind and slide the visible one away.
When the visible ImageViewhas slided away, set it's visibility to GONEand move it behind the second ImageView
Do this for every time a new image is loaded.
This should actually work.
You need a "ViewPager"
https://developer.android.com/training/animation/screen-slide.html
It has all the necessary handles to accommodate "N" number of images - also supports multiple swipe animations - default handlers - efficient memory management - prefetching - you are all in for a feast with this !!
Just make sure you get the "ImageView" in the layout of the "pages" you wish to develop on the "ViewPager".

using animation in imageview while changing image

I have used the code here to animate changing image of an ImageView. But it converts the first image to a white screen and then fade the white screen into the final image (no matter if I use background for ImageView or not).
the same effect is appeared when using slide_out_right and slide_in_left.
Question:
How can I directly go from current Image to a new Image using a custom Animation?
I know that it is possible when using ImageSwitcher but I wanne do it in an ImageView
TransitionDrawable is not the solution because it is applicable only for fade. I wanna use translate or any custom animation.
thanks for any help
Edit:
I think I got the answere, but I am not sure if it an efficient solution:
the white screen is because I am animating the whole ImageView. when it goes out the display what appeared is the Layout background which is white.
To solve the problem, I used two ImageViews and copy the current Image to one and the new image to the another one. animation_in is applied to the imageview containing new image and animation_out to the other one.

Android: how to do this animation?

There is an ImageView with a drawable resource. The animation should begin empty, the resource should progressively appear from the top edge, then it should continue shifting towards the lower edge until it disappear again beyond that.
I'd like to start this animation whenever I want and make it repeat endlessly until I decide to stop it. Any help?
Maybe you can use one of this libraries, this libraries help you and have many examples
https://github.com/2359media/EasyAndroidAnimations
https://github.com/daimajia/AndroidViewAnimations
Also animating resources is possible by writing custom view and modifying onDraw() function, it is not necessary in your case. You need a ViewGroup with an ImageView nested inside. You set your imageview top-padding -imageHeight which make it disappear at the beginning. than you can use property animator (or object animator) to increase top-padding over time up to 0 and dada! now you have your imageview fully shown on the screen.
property animation is an easy concept you can grasp in 5 minutes! Right now i don't have a IDE so there would be no code. good luck

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

Categories

Resources