【问题标题】:Issue in android google map v2 pre ICSandroid google map v2 pre ICS 中的问题
【发布时间】:2013-05-16 10:09:42
【问题描述】:

我已将地图片段放置在 LinearLayout 中,它是 ScrollView 的子级。 当我向下滚动时遇到地图时,地图会在屏幕上留下黑色斑块。 我在 ICS 即之前的设备中面临这个问题。姜饼。有没有人遇到过类似的问题?

【问题讨论】:

标签: android google-maps-android-api-2


【解决方案1】:

我得到了解决方案!

创建一个 MyMapFragment 类

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;

import com.google.android.gms.maps.SupportMapFragment;

public class MyMapFragment extends SupportMapFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        setMapTransparent((ViewGroup) view);
        return view;
    };

    private void setMapTransparent(ViewGroup group) {
        int childCount = group.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = group.getChildAt(i);
            if (child instanceof ViewGroup) {
                setMapTransparent((ViewGroup) child);
            } else if (child instanceof SurfaceView) {
                child.setBackgroundColor(0x00000000);
            }
        }
    }
}

初始化谷歌地图

map = ((MyMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.mapView)).getMap();

在xml里面

<LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="250dp"
            android:layout_marginBottom="15dp"
            android:background="@drawable/mapouter" >

            <fragment
                xmlns:map="http://schemas.android.com/apk/res-auto"
                android:id="@+id/mapView"
                android:name="com.example.MyMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>

【讨论】:

    猜你喜欢
    • 2014-07-18
    • 2016-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多