6

Still showing and hiding view like this:

if(isChecked)
{           
    linearLayoutMap.setVisibility(View.VISIBLE);
}
else 
{
    linearLayoutMap.setVisibility(View.GONE);               
}

but what if I have to show and hide using Slide Up and Slide Down Animation

reVerse
  • 34,477
  • 21
  • 90
  • 83
Sun
  • 6,448
  • 23
  • 73
  • 128

1 Answers1

21

Create below xml in anim folder

slid_down.xml :

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

<translate
    android:duration="1000"
    android:fromYDelta="0"
    android:toYDelta="100%" />
</set>

slid_up.xml

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

<translate
    android:duration="1000"
    android:fromYDelta="100%"
    android:toYDelta="0" />
</set>

Create Amim common util class :

public class MyUtils {

public void SlideUP(View view,Context context)
{
 view.startAnimation(AnimationUtils.loadAnimation(context,
            R.anim.slid_down));
}

public void SlideDown(View view,Context context)
{
 view.startAnimation(AnimationUtils.loadAnimation(context,
            R.anim.slid_up));
}


}
KOTIOS
  • 11,234
  • 3
  • 37
  • 64