使GLSurfaceview透明 可见背景图片

本文介绍如何使GLSurfaceView透明,以便能看到其后的背景图片。通过设置SurfaceView格式为8888,并在Android应用中采用透明主题或者自定义透明样式来实现。在AndroidManifest.xml中为特定Activity应用透明主题,或在res/values中创建styles.xml文件定义透明样式,然后在Activity中应用此样式,从而达到透明效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

以下是从网上搜到的方法,我的程序是要给一个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 ,
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值