Slide up and Slide down animation on Webview in Android
Asked Answered
V

2

6

i have a list of chapters in a list.when user selects a chapter it get expanded and sub topics in that chapter lists. when user select the particular sub topic its contents get loaded in webview on new screen. its all done fine. But i want some functionality on webview. When user slide up the webview, webview should move up side and a new webview from bottom to upside should appear on screen (slide up animation on webview) with next subtopics contents. same in case of slide down when user slides down web view with previous subtopics contents.

Please help how to provide slide up and slide down animation on webview. Thanks

Ventilator answered 8/12, 2011 at 9:25 Comment(2)
check https://mcmap.net/q/1770704/-slide-down-view-in-androidWryneck
hi maneesh thanks for your reply but i have used that methods you r referring. when slide up half of webview is still visible in background and when slides down cached webview is visible.Ventilator
T
12

Apply animation to webview..

Slide down.xml

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate android:fromYDelta="0%p"   
          android:interpolator="@android:anim/accelerate_interpolator"      
    android:toYDelta="100%p" android:duration="2000" />  
</set>

Slide Up.xml

<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">

<translate android:fromYDelta="100%" 
                   android:toXDelta="0" 
                   android:duration="1000" />
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="500" />
</set>

Use Wbeview startAnimation method

Tega answered 8/12, 2011 at 10:16 Comment(5)
Thanks a lot but how to use it on webview statanimation method. Also how to use gesture for slide up that should b used when scroll is at the end of webview and vice-versa. ThanksVentilator
Check it webView.startAnimation(animationObject) method is there.Tega
Thanks dhaval. please assist me for other issue how to use gesture for slide up and down on start of contents and end of contents.Ventilator
There is missing '</set>' in Slide Up animationMoravian
slide up seems to have toXDelta... did you intend to type toYDelta instead?Periphery
O
1

pleas implement OnGestureListener in your activity

and use the following code

detector = new GestureDetector(this, this);
WebView1.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            detector.onTouchEvent(event);
            return true;
        }
    });


@Override
public boolean onDown(MotionEvent e) {
    // TODO Auto-generated method stub
    return false;
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    float dX = e2.getX() - e1.getX();
    float dY = e1.getY() - e2.getY();
    // check is all completed or return with some condition
    if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE) {
// logic for left and right
if(dX>0){
}
  elseif(dX<0)
    }   
    return false;
}

@Override
public void onLongPress(MotionEvent e) {
    // TODO Auto-generated method stub

}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
    // TODO Auto-generated method stub
    return false;
}

@Override
public void onShowPress(MotionEvent e) {
    // TODO Auto-generated method stub

}

@Override
public boolean onSingleTapUp(MotionEvent e) {
    // TODO Auto-generated method stub
    return false;
}

fling method will handle the touch event if x direction and you can make it work in y axis as well

Oasis answered 5/7, 2012 at 10:27 Comment(3)
is your problem solved or you are looking for some thing elseOasis
Hi vipin.. Sorry for late reply.. and thanks a lot for your help...Actually the requirement had changed so i left that part..anyways thanks a lot once again..Ventilator
it"s alright but when you ask question and people answer it please try them whether your requirement may change .. so that people reading your thread must get the right answer ...........Oasis

© 2022 - 2024 — McMap. All rights reserved.