1.什么是Surface?
简单地说Surface对应了一块屏幕缓冲区,每个window对应一个Surface,任何View都是画在Surface上的,传统的view共享一块屏幕缓冲区,所有的绘制必须在UI线程中进行
2.什么是SurfaceView?
说SurfaceView是一个View也许不够严谨,然而从定义中 public class SurfaceView extends View {...}显示SurfaceView确实是派生自View,但是SurfaceView却有着自己的Surface,继续看SurfaceView的源码:
if (mWindow == null) {
mWindow = new MyWindow(this);
mLayout.type = mWindowType;
mLayout.gravity = Gravity.LEFT|Gravity.TOP;
mSession.addWithoutInputChannel(mWindow, mWindow.mSeq, mLayout,
mVisible ? VISIBLE : GONE, mContentInsets);
}
很明显,每个SurfaceView创建的时候都会创建一个MyWindow,new MyWindow(th
简单地说Surface对应了一块屏幕缓冲区,每个window对应一个Surface,任何View都是画在Surface上的,传统的view共享一块屏幕缓冲区,所有的绘制必须在UI线程中进行
2.什么是SurfaceView?
说SurfaceView是一个View也许不够严谨,然而从定义中 public class SurfaceView extends View {...}显示SurfaceView确实是派生自View,但是SurfaceView却有着自己的Surface,继续看SurfaceView的源码:
if (mWindow == null) {
mWindow = new MyWindow(this);
mLayout.type = mWindowType;
mLayout.gravity = Gravity.LEFT|Gravity.TOP;
mSession.addWithoutInputChannel(mWindow, mWindow.mSeq, mLayout,
mVisible ? VISIBLE : GONE, mContentInsets);
}
很明显,每个SurfaceView创建的时候都会创建一个MyWindow,new MyWindow(th