Android - Animation, hiding and displaying a menu

1

I have a problem creating an animation. I have a button in the action bar that clicks on it, or displays or hides a menu bar. So far it is displaying or hiding using GONE and VISIBLE. I would like to add an animation, this menu is just below the action bar, so when clicking to hide the menu, I would like it to move up, hiding it. When clicking to show the menu, I would like it to move down, showing it. Another problem is that the rest of the layout should follow the movement that is chosen. Does anyone know of an example for this problem? Thanks!

    
asked by anonymous 12.05.2015 / 23:13

1 answer

1

To animate a component is very simple. See the example below:

EditText cadastroEdtNome
cadastroEdtNome.startAnimation(AnimationUtils.loadAnimation(CadastroCliente.this, R.anim.slide_up));
Ready! Now you just need the XML code for the animations. What I sent you is this one:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >

    <scale
        android:duration="250"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:interpolator="@android:anim/linear_interpolator"
        android:toXScale="1.0"
        android:toYScale="0.0" />

</set>

But there are many others on the internet , and you can even create yours if you want!

    
17.05.2015 / 02:17