I am new to android development.I wanted to learn that how will i be able to display a view when user slide upwards. See my Layout.! Image of Layout
Now here when user slides up the blue colored view,i want a view to be displayed and also when user slide down the view should be gone. As i am knew and tried finding on Google i didn't got any success so please do help me
I tried doing this but nothing happend
public class MainActivity extends ActionBarActivity {
private LinearLayout slideUp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
slideUp = (LinearLayout) findViewById(R.id.ll_slideUp);
slideUp.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent touchevent) {
float x1 = 0, y1 = 0, x2, y2;
switch (touchevent.getAction()) {
// when user first touches the screen we get x and y coordinate
case MotionEvent.ACTION_DOWN: {
x1 = touchevent.getX();
y1 = touchevent.getY();
break;
}
case MotionEvent.ACTION_UP: {
x2 = touchevent.getX();
y2 = touchevent.getY();
//if left to right sweep event on screen
if (x1 < x2) {
Toast.makeText(MainActivity.this, "Left to Right Swap Performed", Toast.LENGTH_LONG).show();
}
// if right to left sweep event on screen
if (x1 > x2) {
Toast.makeText(MainActivity.this, "Right to Left Swap Performed", Toast.LENGTH_LONG).show();
}
// if UP to Down sweep event on screen
if (y1 < y2) {
Toast.makeText(MainActivity.this, "UP to Down Swap Performed", Toast.LENGTH_LONG).show();
}
//if Down to UP sweep event on screen
if (y1 > y2) {
Toast.makeText(MainActivity.this, "Down to UP Swap Performed", Toast.LENGTH_LONG).show(); // Show your view here when use slides up
}
break;
}
}
return false;
}
});
}
}