首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

SurfaceView背景设立为透明

2012-11-19 
SurfaceView背景设置为透明将SurfaceView背景设置为透明,主要添加以下几句话就可以了:1.在SurfaceView创建

SurfaceView背景设置为透明
将SurfaceView背景设置为透明,主要添加以下几句话就可以了:
1.在SurfaceView创建后设置一下下面的参数:
setZOrderOnTop(true);
getHolder().setFormat(PixelFormat.TRANSLUCENT);

如:
SurfaceTrendView trendView = new SurfaceTrendView(this);
trendView.setClickable(false);
trendView.setZOrderOnTop(true);
trendView.holder.setFormat(PixelFormat.TRANSPARENT);//设置背景透明

2.还有在draw方法中绘制背景颜色的时候以下面的方式进行绘制就可以实现SurfaceView的背景透明化
canvas.drawColor(Color.TRANSPARENT,Mode.CLEAR);

热点排行