我正在使用自定义表面视图。但是没有出现绘图并且视图是全黑的:
public class SV extends SurfaceView {
Context context;
public SV (Context a_context)
{
super(a_context);
context = a_context;
}
@Override
public void draw (Canvas c)
{
c.drawColor(0xFFFF0000);
Paint p = new Paint();
p.setColor(0xFFFFFFFF);
c.drawCircle(c.getWidth()/2, c.getHeight()/2, 150, p);
}
@Override
public void onDraw (Canvas c)
{
c.drawColor(0xFF0088FF);
}
}
在 onCreate 活动中:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
SV sv = new SV (this);
setContentView(sv);
}