MapFragment在滚动型MapFragment

2023-09-12 10:52:06 作者:余厌

我有新的一个MapFragments在滚动型。其实这是一个 SupportMapFragment ,但无论如何。它的工作原理,但有两个问题:

I have one of the new MapFragments in a ScrollView. Actually it's a SupportMapFragment, but anyway. It works, but there are two problems:

在滚动,它留下了黑色的面具背后。黑色覆盖的确切位置的地图是,除孔所在的+/-变焦按钮是该区域。见下面的截图。这是在Android 4.0。

When scrolled, it leaves a black mask behind. The black covers exactly the area where the map was, except for a hole where the +/- zoom buttons were. See screenshot below. This is on Android 4.0.

视图不使用 requestDisallowInterceptTouchEvent()当用户与地图上prevent交互的滚动型拦截触动,所以如果你尝试在地图上下平移,它只是滚动包含滚动型。我理论上可以得出一个视图类图形页面并添加功能,但我怎样才能得到 MapFragment 使用我的自定义图形页面,而不是标准的?

The view doesn't use requestDisallowInterceptTouchEvent() when the user interacts with the map to prevent the ScrollView intercepting touches, so if you try to pan vertically in the map, it just scrolls the containing ScrollView. I could theoretically derive a view class MapView and add that functionality, but how can I get MapFragment to use my customised MapView instead of the standard one?

推荐答案

应用透明图像上的MapView片段似乎解决问题。这不是prettiest,但它似乎工作。下面是一个XML片段,显示这一点:

Applying a transparent image over the mapview fragment seems to resolve the issue. It's not the prettiest, but it seems to work. Here's an XML snippet that shows this:

<RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="300dp" >

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.MapFragment"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>

        <ImageView
            android:id="@+id/imageView123"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/temp_transparent" />         
</RelativeLayout>