论坛首页 移动开发技术论坛

关于 surfaceview 背景覆盖的问题

浏览 10475 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-02-16   最后修改:2012-02-24

本人开发过程中,发现出了黑色,不能设置其他颜色,如果设置了,就画不出东西了,后来网上终于找到了,我是在xml中设置的背景,我想在class中设置应该也可以

xml

<SurfaceView android:id="@+id/SurfaceView01"
		android:layout_height="fill_parent" 
		android:layout_width="fill_parent"
	    android:background="#FFFFFF"
		></SurfaceView>

 

 

class中需要加入的东西是

//画板和画笔
		sfv = (SurfaceView) this.findViewById(R.id.SurfaceView01); 
		sfv.setOnTouchListener(new TouchEvent());
		
        mPaint = new Paint(); 
          
        mPaint.setColor(Color.BLACK);// 画笔为黑色  
        mPaint.setStrokeWidth(1);// 设置画笔粗细 
        // 设置样式-填充    
        mPaint.setStyle(Style.FILL);    
        sfv.setZOrderOnTop(true);      // 这句不能少
        sfv.getHolder().setFormat(PixelFormat.TRANSPARENT);

 

   发表时间:2012-02-22  
mPaint.setColor(Color.BLACK);// 画笔为绿色
介是什么意思??
0 请登录后投票
   发表时间:2012-02-24  
b87936260 写道
mPaint.setColor(Color.BLACK);// 画笔为绿色
介是什么意思??

不好意思注释错了,这个应该是设置画笔的颜色为黑色
0 请登录后投票
论坛首页 移动开发技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics