Android Up Down Button : Layouts and Animations

Slide Up / Down Translate
Many would be interested to perform some kindaa of slide up or bottom up animation of images on a button click.
Translate animation can be used to perform this. public TranslateAnimation (float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)

1. MainActivity.java

package com.tutorialsee;

import com.tutorialsee.R;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class MainActivity extends Activity {
LinearLayout _lin,linn2;
Button _btn;
ImageView gobtn,sdsdf,second;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
_btn = (Button)findViewById(R.id.btn);
gobtn = (ImageView)findViewById(R.id.gobtn);
sdsdf = (ImageView)findViewById(R.id.sdsdf);
_lin = (LinearLayout)findViewById(R.id.linn);
linn2 = (LinearLayout)findViewById(R.id.linn2);
second = (ImageView)findViewById(R.id.second);

sdsdf.setOnClickListener(new OnClickListener(){

@SuppressWarnings("unused")
@Override
public void onClick(View v) {
Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.left);
Animation slideDown = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.right);

if(linn2.getVisibility()==View.INVISIBLE){
//_btn.setBackgroundColor(Color.parseColor("#E91E63"));
linn2.startAnimation(slideUp);
linn2.setVisibility(View.VISIBLE);
_btn.setVisibility(View.INVISIBLE);
}
}
});

_btn.setOnClickListener(new OnClickListener(){

@SuppressWarnings("unused")
@Override
public void onClick(View v) {
Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);
Animation slideDown = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down);

if(_lin.getVisibility()==View.INVISIBLE){
_btn.setBackgroundColor(Color.parseColor("#E91E63"));
_lin.startAnimation(slideUp);
_lin.setVisibility(View.VISIBLE);

}
}
});

gobtn.setOnClickListener(new OnClickListener(){

@SuppressWarnings("unused")
@Override
public void onClick(View v) {
Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);
Animation slideDown = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down);

if(_lin.getVisibility()==View.VISIBLE){
_btn.setBackgroundColor(Color.parseColor("#FAFAFA"));
_lin.startAnimation(slideDown);
_lin.setVisibility(View.INVISIBLE);

}
}
});

second.setOnClickListener(new OnClickListener(){

@SuppressWarnings("unused")
@Override
public void onClick(View v) {
Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.left);
Animation slideDown = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.right);

if(linn2.getVisibility()==View.VISIBLE){
_btn.setBackgroundColor(Color.parseColor("#FAFAFA"));
linn2.startAnimation(slideDown);
linn2.setVisibility(View.INVISIBLE);
_btn.setVisibility(View.VISIBLE);

}
}
});
}
}

2. activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#E91E63" >

    <LinearLayout
        android:id="@+id/sddsd"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:orientation="vertical"
        android:padding="5dp" >

        <ImageView
            android:id="@+id/sdsdf"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:layout_marginTop="0.02dp"
            android:background="@drawable/menu"
            android:contentDescription="@drawable/menu"
            android:padding="15dp"
            android:text="@string/Go"
            android:textColor="#FAFAFA" />
    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerInParent="true"
        android:text="@string/Welcome"
        android:textColor="#FAFAFA"
        android:textSize="17sp" />

    <Button
        android:id="@+id/btn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#FAFAFA"
        android:gravity="center"
        android:text="@string/Submit"
        android:textColor="#E91E63"
        android:textSize="17sp" />

    <LinearLayout
        android:id="@+id/linn"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FAFAFA"
        android:orientation="vertical"
        android:visibility="invisible" >

        <LinearLayout
            android:id="@+id/lindn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#E91E63"
            android:gravity="end"
            android:padding="5dp" >

            <ImageView
                android:id="@+id/gobtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="10dp"
                android:layout_marginTop="0.02dp"
                android:background="@drawable/close"
                android:contentDescription="@drawable/close"
                android:padding="15dp"
                android:text="@string/Go"
                android:textColor="#FAFAFA" />
        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:text="@string/A" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/B" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/C" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linn2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="35dp"
        android:background="#FAFAFA"
        android:orientation="vertical"
        android:visibility="invisible" >

        <LinearLayout
            android:id="@+id/lindn2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#E91E63"
            android:gravity="end"
            android:padding="5dp" >

            <ImageView
                android:id="@+id/second"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="0.02dp"
                android:background="@drawable/close"
                android:contentDescription="@drawable/close"
                android:padding="15dp"
                android:text="@string/Go"
                android:textColor="#FAFAFA" />
        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:text="@string/A" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/B" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/C" />
    </LinearLayout>

</RelativeLayout>