SurfaceView显示黑屏?

时间:2015-01-09 10:45:17

标签: android surfaceview

我正在尝试让我的SurfaceView工作但我得到了黑屏。我试图更改canvas.drawRGB(02, 02, 150);的颜色编号,但没有帮助。我不知道原因是什么。我感谢任何帮助!



package com.test;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MyBringBackSurface extends SurfaceView implements Runnable {

	SurfaceHolder ourHolder;
	Thread ourThread = null;
	boolean isRunning;

	public MyBringBackSurface(Context context) {
		super(context);
		ourHolder = getHolder();
		ourThread = new Thread(this);
		ourThread.start();

	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		while (isRunning) {
			if (!ourHolder.getSurface().isValid())
				continue;
			Canvas canvas = ourHolder.lockCanvas();
			canvas.drawRGB(02, 02, 150);
			ourHolder.unlockCanvasAndPost(canvas);
		}

	}

}




0 个答案:

没有答案