android - map in listview header

非 Y 不嫁゛ 提交于 2019-12-06 04:30:22

This is an example but not the solution. In this example I've made a custom scrollview which returns false when scrolled in the x-direction (indicating that the event haven't been handled and should be passed on to the next view):

public class CustomScrollView extends ScrollView {
    private GestureDetector mGestureDetector;
    View.OnTouchListener mGestureListener;

    public CustomScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mGestureDetector = new GestureDetector(new YScrollDetector());
        setFadingEdgeLength(0);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
    }

    // Return false if we're scrolling in the x direction  
    class YScrollDetector extends SimpleOnGestureListener {
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            if(Math.abs(distanceY) > Math.abs(distanceX)) {
                return true;
            }
            return false;
        }
    }
}

You need to do something similar in a certain region of your viewswitcher. So you need to modify the basic viewswitchercomponent and make your own variant.

As an alternative to the above suggestion I'd consider not doing it. If you look at apps around using maps this is really not a normal behavior and I doubt it'll run very smooth or make a good user interaction. Maps in general works best when they get as much space as possible. Take a look at some basic map apps: Google Navigation, Google Maps, Google latitude, Yelp.

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