0
为什么当我在画布对象 上使用drawRect()并且在onCreate方法中声明它时,矩形不显示。为什么当我使用drawRect()时矩形不显示?
代码
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activitymain);
Chronometer stopWatch = (Chronometer)findViewById(R.id.chrono);
mDrawingActivity = (DrawingActivity)findViewById(R.id.the_canvas);
Button b = (Button)findViewById(R.id.startButton);
b.setText("start");
b.setOnClickListener(this);
}
的OnDraw()方法
protected void onDraw(Canvas Square)
{
super.onDraw(Square);
Paint squareColor = new Paint();
squareColor.setColor(Color.CYAN); // change the box color to cyan
Square.drawRect(100,100,100,100, squareColor);
return;
}
澄清:即使是按钮和记时计没有示出过和程序被强制关闭。
请提供您正在绘制矩形的代码 – Dimmerg
只需在文档中阅读Canvas.drawRect()的参数'right'和'bottom'就意味着什么 –