su易做图ceview
su易做图ceview:可以使用一个线程来绘图,程序不会因为绘图而失去响应
1.自定义一个su易做图ceview:
class
MySu易做图ceView extends
Su易做图ceView implements
Su易做图ceHolder.Callback
2.实现Su易做图ceHolder.Callback接口的3个回调方法,在su易做图ceCreated中启动绘制线程:
@Override
public
void
su易做图ceChanged(Su易做图ceHolder holder, int
format, int
width,
int
height) {
//
TODO Auto-generated method stub
}
@Override
public
void
su易做图ceCreated(Su易做图ceHolder holder) {
//
启动自定义线程
new
Thread(new
MyThread()).start();
}
@Override
public
void
su易做图ceDestroyed(Su易做图ceHolder holder) {
//
TODO Auto-generated method stub
}
3.注册callback:
public
MySu易做图ceView(Context context) {
super(context);
BackgroundImage =
BitmapFactory.decodeResource(getResources(),
R.drawable.bg);
QuestionImage =
BitmapFactory.decodeResource(getResources(),
R.drawable.question);
Holder =
this.getHolder();//
获取holder
Holder.addCallback(this);
}
4.在绘制线程中绘画:
canvas
=
Holder.lockCanvas();//
获取画布
.
.
.
.//绘画,如canvas.drawBitmap等
Holder.unlockCanvasAndPost(canvas);//
解锁画布,提交画好的图像
补充:移动开发 , Android ,