Show / hide the view using the animation "Slide up and down"

Showing and hiding the view:

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

but what if I need to show and hide the use of slide shows and slide animations

+4
source share
1 answer

Create below xml in your animation 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 a generic Amim utility 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));
}


}
+20
source

All Articles