Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show/Hide View using Slide Up and Down Animation

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

like image 838
Sun Avatar asked Jan 30 '15 12:01

Sun


1 Answers

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));
}


}
like image 85
KOTIOS Avatar answered Nov 03 '22 19:11

KOTIOS