如何覆盖GLSurfaceView在Android中一个图形页面?图形、页面、GLSurfaceView、Android

由网友(灬煞血江楜)分享简介:我要创建在Android中,在那里我可以显示我目前覆盖一个简单的图像上的MapView重新present的位置position.Instead一个简单的基于地图的应用程序,我想叠加GLSurfaceView上的MapView 。但我不知道如何来实现这一目标。有没有办法做到这一点?请任何人知道的解决方案,帮助我。I w...

我要创建在Android中,在那里我可以显示我目前覆盖一个简单的图像上的MapView重新present的位置position.Instead一个简单的基于地图的应用程序,我想叠加GLSurfaceView上的MapView 。但我不知道如何来实现这一目标。有没有办法做到这一点?请任何人知道的解决方案,帮助我。

I want to create a simple Map based application in android ,where i can display my current position.Instead of overlaying a simple Image on the MapView to represent the position, i want to overlay the GLSurfaceView on the MapView. But i don't know how to achieve this. Is there any way to do that?. Please anybody knows the solution help me.

推荐答案

我被困在一个类似的问题,直到我看了看文档,并意识到,图形页面扩展的ViewGroup ,所以上重叠 GlSurfaceView 实际上最终是pretty的琐碎。

I was stuck on a similar problem until I looked at the documentation and realized that MapView extends ViewGroup, so overlaying a GlSurfaceView actually ends up being pretty trivial.

MapView.addView(...) MapView.LayoutParams 允许你一些pretty的有用像地方查看在地图上的特定的GeoPoint

MapView.addView(...) and MapView.LayoutParams allow you to some pretty useful things like place a View at a specific GeoPoint on the map.

详细资料:https://developers.google.com/maps/documentation/android/reference/com/google/android/maps/MapView.LayoutParams.html

下面是我所做的:

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mapview);

    MapView map_view = (MapView) findViewById(R.id.map_view);

    CustomGlView gl_view = new CustomGlView(this);

    // This is where the action happens.
    map_view.addView(gl_view, new MapView.LayoutParams(
            MapView.LayoutParams.FILL_PARENT, 
            MapView.LayoutParams.FILL_PARENT, 
            0,0, 
            MapView.LayoutParams.TOP_LEFT
            )
        );
}

另外还做上述各国的解决方案。我子类GlSurfaceView,所以我的看起来略有不同:

Plus also do what the solution above states. I sub-classed GlSurfaceView, so mine looks slightly different:

public CustomGlView(Context context) {
    super(context);
    YourCustomGlRenderer renderer = new YourCustomGlRenderer();
    setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    setRenderer(renderer);
    getHolder().setFormat(PixelFormat.TRANSLUCENT);

    // Have to do this or else 
    // GlSurfaceView wont be transparent.
    setZOrderOnTop(true);  
}
阅读全文

相关推荐

最新文章