I’m porting an app from iOS to Android. In the iOS app, there is an animation of a view “dropping down” while pushing the views beneath it down with it. See example here (download this app & click the “Join” button to see the drop down panel effect):
AppFreeway
I’ve been trying to replicate this effect in Android, I got pretty close by creating a TranslateAnimation in XML and later calling setAnimation for the view that’s dropping down:
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%" android:toXDelta="0%"
android:fromYDelta="-100%" android:toYDelta="0%"
android:duration="500" />
anim = AnimationUtils.loadAnimation(
this, R.anim.contact_animation_enter);
joinPanel.startAnimation(anim);
The problem is when I add the view to the parent view using parent.addView(panel, 0) because the parent instantly moves everything down and only later the animation begins. If you watch the iOS version, you’ll see that when the “Join” button is clicked, everything gets animated down as the drop down panel moves into view.
Any ideas on how to achieve the same effect?
This is how I did it in a custom view I created. I had the view I wanted to display already coded into the xml layout file with
android:visibility = "gone". The only thing I haven’t figured out yet is when the EditText box is scaling, it enlarges the text, then shrinks it to normal size. If I find a solution to this problem I will post it.And here is my
fade_in_from_top.xmlanimation file: