Android: how to do this animation? - android

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

Related

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".

Textviews don't get animated in a SharedContentTransitionAnimation

I came across this solution: How can I scale textviews using shared element transitions?
But this is not working, when I use this solution, I don't get any animations at all.
The problem is the size of the text inside textviews, and the color of the text. They don't get animated and the movement animation looks really weird. Should I make a animation that runs after the SharedContentTransitions have completed? Or is there a fix that makes this issue a whole lot easier to fix?

Rotating, Translating, and Scalling compound views on android

I have a custom compound view consisting of a textview above an imagebutton (wrapped in LinearLayout). I would like to be able to apply certain gesture-based transformations on it including:
rotating the imageview with two fingers about it's center. TextView stays same orientation
Pinch/zoom to scale the imageview (textview should remain the same size)
move the compound view around the layout
In this scenario there will be several of these views populating a relative/framelayout. The user should be able to interact/modify each view individually.
I've achieved at least a partial implementation for the moving around, based off the answer here: https://stackoverflow.com/a/18806475/2879847. I've read/tried some implementations of the scaling/rotation functions but they seem to apply only to the drawable/bitmap rather than the containing view object so, I'm not sure where to go from there. Any help would be great
Many Thanks - let me know if you guys need any further clarifications.
I've managed to achieve what i want (seems to be working well) - will post some code once my workload dies down.

How to cross-fadeing image in Android

Basically, I have images that I'd like to to update them sequentially into the same view to create custom ProgressBar.
I found Tumblr to do just that with their ProgressBar(ImageView?).
Here I put the animation side-by-side to show how the image actually cross-fade from Aa into a camera.
Exactly what I wanted:
Cross-fading effect
Indeterminate
Use the same view (I dumped view hierarchy to check)
Animation during transition (The image actually pop a little when spinning and cross-fading into the next image)
So far I have tried:
1. Frame Animation,
this allows for unlimited item(s) with definable durtion. However, it
doesn't cross-fade the image and there's no way to listen to the
transition's event to apply other animation, etc.
2. Transition Drawable, this allows cross-fading between EXACTLY two drawables. So this doesn't allow for the number of items and interminate duration as well.
I also came across CrossFadeDrawable by Romain Guy just now but it looks like it's only coded to support only two Drawable.
Right now I am not very sure if I'm approaching in the right direction or is there something I need to learn in order to do this kid of effect?
I'm not sure if you are approaching this direction but isn't this what you are looking for:
http://www.youtube.com/watch?v=atH3o2uh_94

ImageView animation like the Android 4.0+ contact editor

I would like to animate my ImageView like the contact editor (the read only mode) in Android 4.0+ does (I am not sure about the version).
But I don't know where to start. I tried to figure out what the source code does, but it is really complicated and I am not even sure, if I am looking at the right source code (PhotoSelectionActivity?).
So, here is what I would like to do:
I have an ImageView (400dp x 200dp, width x height) and a quadratic image resource. I would like to draw my image in that ImageView using the centerCrop scale type (done so far). But when the user clicks the ImageView, it should expand to its full size (if possible do not change the layout size, because it is not the only view in the linear layout), the background (if possible) should fade out.
Any ideas?
Here is an image of the start view:
and when the user clicks the image, an animation should start, ending with this view (keep in mind, that the contacts details are still there, they are just behind the image):
I hope it is clearer now.
To achieve this create two corresponding animations (scale and fade out) with Property Animations
Use NineOldAnroids for backwards compatability with Android 2.x.

Categories

Resources