Google Map V2和导航抽屉 [英] Google map V2 and navigation drawer
问题描述
问题
我想在Navigate Drawer
中使用Google Map V2
,但不能禁用导航抽屉
I want to use Google Map V2
in Navigate Drawer
but I can't disable Navigate Drawer
,然后在触摸地图时将触摸处理程序提供给地图.我该怎么办???
and give touch handler to the map when it was touched. What should I do ???
注意
我以前遇到过类似的问题...
I have experience the similar problem like this before...
我想在Navigate Drawer
中使用SeekBar
,它不能滚动SeekBar.
I would like to use SeekBar
in Navigate Drawer
and it can't scroll the SeekBar.
当时,我可以使用onTouchListener()
直接为SeekBar存档,但是现在不能.
At that time, I can archive it by using onTouchListener()
for SeekBar directly but now it cannot.
推荐答案
解决方案
因此,这是我的解决方案,感谢这篇文章,我已经修改了一些代码来归档我的目标.
So, here is my solution thank to this post, I have adapt some code to archive my goal.
STEP 1 ::为MySupportMapFragment
第2步 ::覆盖dispatchTouchEvent()
并执行以下操作
STEP 2 :: override dispatchTouchEvent()
and do as the following
public class TouchableWrapper extends FrameLayout {
public TouchableWrapper(Context context) {
super(context);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
ViewParent v;
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
v = this.getParent();
v.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
v = this.getParent();
v.requestDisallowInterceptTouchEvent(false);
break;
}
return super.dispatchTouchEvent(ev);
}
}
步骤3 ::创建MySupportMapFragment类并将其与TouchableWrapper绑定
STEP 3 :: Create MySupportMapFragment Class and bind it with TouchableWrapper
public class MySupportMapFragment extends SupportMapFragment {
public View mOriginalContentView;
public TouchableWrapper mTouchView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
mOriginalContentView = super.onCreateView(inflater, parent, savedInstanceState);
mTouchView = new TouchableWrapper(getActivity());
mTouchView.addView(mOriginalContentView);
return mTouchView;
}
@Override
public View getView() {
return mOriginalContentView;
}
}
第4步 ::将原始的XML Map Fragment更改为自定义的
STEP 4 :: Change your original xml Map Fragment to your custom one
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/buttonBar"
class="com.myFactory.myApp.MySupportMapFragment"
/>
是的,现在Google Map V2
就可以拖入Navigating Drawer
Yeah, That's all now the Google Map V2
can drag in the Navigating Drawer
这篇关于Google Map V2和导航抽屉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!