1
我需要將谷歌地圖視圖放入SwipeRefreshLayout中,問題是SwipeRefreshLayout覆蓋觸摸事件的谷歌地圖。當我嘗試向上滾動地圖SwipeRefreshLayout事件正在觸發。我如何禁用SwipeRefreshLayout事件當我滾動谷歌地圖?谷歌地圖視圖裏面SwipeRefreshLayout
我需要將谷歌地圖視圖放入SwipeRefreshLayout中,問題是SwipeRefreshLayout覆蓋觸摸事件的谷歌地圖。當我嘗試向上滾動地圖SwipeRefreshLayout事件正在觸發。我如何禁用SwipeRefreshLayout事件當我滾動谷歌地圖?谷歌地圖視圖裏面SwipeRefreshLayout
我在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;
}
}
把你當前的代碼 – Stallion