Thursday, 16 October 2014

scroll up and down animation in android ?

Scroll-down


<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="-100%" android:toYDelta="0%" android:duration="1000"/>
</set>


Scroll-up


<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="0%" android:toYDelta="-100%" android:duration="500"/>
</set>


call them:


relatv.setOnTouchListener(new OnTouchListener () {
 public boolean onTouch(View view, MotionEvent event) {
   if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
   
    Animation slide = AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.scrollup);
button.startAnimation(slide);
button.setVisibility(View.GONE);

   
   } else if (event.getAction() == event.ACTION_UP) {
   
    button.setVisibility(View.VISIBLE);
   
    Animation slide1 = AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.scrolldown);
    button.startAnimation(slide1);
   }
 
return false;
 }
});

No comments:

Post a Comment