【问题标题】:GoogleMaps view inside SwipeRefreshLayoutSwipeRefreshLayout 内的 GoogleMaps 视图
【发布时间】:2016-10-04 20:37:03
【问题描述】:

我需要在 SwipeRefreshLayout 中放置谷歌地图视图,问题是 SwipeRefreshLayout 在触摸事件上覆盖谷歌地图。当我尝试向上滚动地图时,SwipeRefreshLayout 事件被触发。滚动谷歌地图时如何禁用 SwipeRefreshLayout 事件?

【问题讨论】:

  • 贴出你当前的代码

标签: android google-maps swiperefreshlayout


【解决方案1】:

我在 Shiba J 提出的this 线程中找到了解决这个问题的方法。我扩展了 SwipeRefreshLayout 并覆盖了 onInterceptTouchEvent。

public class OverviewSwipeRefreshLayout extends SwipeRefreshLayout {

    public OverviewSwipeRefreshLayout(Context context) {
        super(context);
    }

    public OverviewSwipeRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        final int action = ev.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                super.onTouchEvent(ev);
                break;
            case MotionEvent.ACTION_MOVE:
                return false;
            case MotionEvent.ACTION_CANCEL:
                super.onTouchEvent(ev);
                break;
            case MotionEvent.ACTION_UP:
                return false;
            default:
                break;
        }

        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        super.onTouchEvent(ev);
        return true;
    }
}

【讨论】:

  • 不幸的是,这对我不起作用。它是特定于布局的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-22
  • 1970-01-01
相关资源
最近更新 更多