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'就意味着什麼 –