以下是从网上搜到的方法,我的程序是要给一个activity加背景图片,activity上有一个GLSurfaceview,只有使GLSurfaceview透明之后才能看到背景图片。
参考:http://www.bangchui.org/read.php?tid=14982
http://www.bangchui.org/read.php?tid=16672
如何实现一个透明的GLSurfaceview,Surfaceview与GLSurfaceview原理类似。
一 .将surfaceview 的格式设置为8888.默认是565的,不透明
public
class
TranslucentGLSurfaceViewActivity
extends
Activity {
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
// Create our Preview view and set it as the content of our
// Activity
mGLSurfaceView =
new
GLSurfaceView(
this
);
// We want an 8888 pixel format because that's required for
// a translucent window.
// And we want a depth buffer.
mGLSurfaceView.setZOrderOnTop(true);//将view放到顶端
mGLSurfaceView.setEGLConfigChooser(
8
,
8
,
8
,
8
,
16
,