這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)Android應(yīng)用中利用SurfaceView截屏?xí)r出現(xiàn)黑屏如何解決,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
創(chuàng)新互聯(lián)公司是專業(yè)的遜克網(wǎng)站建設(shè)公司,遜克接單;提供成都網(wǎng)站制作、做網(wǎng)站,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行遜克網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!1、首先看我們一般是怎么用SurfaceView的
public class SuperSurfaceView extends SurfaceView implements SurfaceHolder.Callback { SurfaceHolder surfaceHolder; public SuperSurfaceView(Context context) { super(context); surfaceHolder = this.getHolder(); surfaceHolder.addCallback(this); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } @Override public void surfaceCreated(SurfaceHolder holder) { new Thread(new MyThread()).start(); } @Override public void surfaceDestroyed(SurfaceHolder holder) { } class MyThread implements Runnable { @Override public void run() { Canvas canvas = surfaceHolder.lockCanvas(null);//獲取畫布 Paint mPaint = new Paint(); mPaint.setColor(Color.BLUE); canvas.drawRect(new RectF(100, 100, 1000, 550), mPaint); surfaceHolder.unlockCanvasAndPost(canvas);//解鎖畫布,提交畫好的圖像 } } }