我已将地图片段放在LinearLayout中,而LinearLayout是ScrollView的子代。 当我向下滚动时遇到地图时,地图会在屏幕上留下黑色补丁。 我在ICS之前的设备中遇到了这个问题。姜饼。有没有人遇到过类似的问题?
答案 0 :(得分: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);
}
}
}
}
初始化GoogleMap
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>