[英]Issue in android google map v2 pre ICS
我将地图片段放置在LinearLayout内,它是ScrollView的子级。 当我向下滚动时遇到地图时,地图在屏幕上会留下黑色斑点。 我在ICS之前的设备中正面临这个问题。 姜饼。 有没有人遇到过类似的问题?
我找到了解决方案!
创建一个类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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.