Pull to Zoom Animation

六眼飞鱼酱① 提交于 2019-12-03 03:07:07

Check out this project:

https://github.com/Gnod/ParallaxListView

If you combine it with the ViewPagerIndicator library, you pretty much get Tinder's profile page feature set

https://github.com/JakeWharton/Android-ViewPagerIndicator

bgoeschi

I think the easiest way is to override the onTouchEvent method of View.

Something like this:

boolean inZoom = false;
float prevY = 0;

@Override
public boolean onTouchEvent(MotionEvent event) {
    float eventY = event.getY();
    float eventX = event.getX();
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        if(touchedTheImage(eventX, eventY)){
            setZoomCenter(eventX, eventY);
            prevY = eventY;
            inZoom = true;
            return true;
        }
        break;
    case MotionEvent.ACTION_MOVE:
        if(inZoom){
            changeZoomLevel(prevY, eventY);
            return true;
        }
        break;
    case MotionEvent.ACTION_UP:
        if(inZoom){
            resetZoomLevel();
            inZoom = false;
            return true;
        }
        break;
    }
  return false;
}

EDIT: for the animation part consider this post: https://stackoverflow.com/a/6650473/3568892

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!