Google 地图在底部 Sheet
Google Map inside Bottom Sheet
我想创建一个视图,其中要在 BottomSheetFragment 中显示 google 地图。目前,我的视图也在响应用户手势以更改 bottom sheet 状态,但我需要手势仅在地图上工作(例如,用于地图平移)。我只希望 closeBottomSheetLinearLayout 在滚动时更改 bottom sheet 状态。可能吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorGray"
android:elevation="10dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/closeBottomSheetLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:color/white">
...
</LinearLayout>
<pl.renesans.renesans.SquareLinearLayout
android:id="@+id/mapLayout"
android:layout_width="match_parent"
android:layout_height="0dp">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".tour.TourActivity"/>
</pl.renesans.renesans.SquareLinearLayout>
</LinearLayout>
提前致谢
我必须以这种方式实现 onInterceptTouchEvent(MotionEvent ev),它起作用了。
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
getParent().requestDisallowInterceptTouchEvent(false);
break;
default:
break;
}
return super.onInterceptTouchEvent(ev);
}
我想创建一个视图,其中要在 BottomSheetFragment 中显示 google 地图。目前,我的视图也在响应用户手势以更改 bottom sheet 状态,但我需要手势仅在地图上工作(例如,用于地图平移)。我只希望 closeBottomSheetLinearLayout 在滚动时更改 bottom sheet 状态。可能吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorGray"
android:elevation="10dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/closeBottomSheetLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:color/white">
...
</LinearLayout>
<pl.renesans.renesans.SquareLinearLayout
android:id="@+id/mapLayout"
android:layout_width="match_parent"
android:layout_height="0dp">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".tour.TourActivity"/>
</pl.renesans.renesans.SquareLinearLayout>
</LinearLayout>
提前致谢
我必须以这种方式实现 onInterceptTouchEvent(MotionEvent ev),它起作用了。
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
getParent().requestDisallowInterceptTouchEvent(false);
break;
default:
break;
}
return super.onInterceptTouchEvent(ev);
}