アプリで長方形を動的に描画していますが、何らかの理由で右の境界線が表示されません。他の 3 つの境界線が表示されます。カスタムビューのコードは次のとおりです。
private class RectView extends View{
int leftX, rightX, topY, bottomY;
boolean isAppt;
private Paint rectPaint;
private Rect rectangle;
String time;
public RectView(Context context, int _leftX, int _rightX, int _topY, int _bottomY,
boolean _isAppt, String _time){
super(context);
leftX = _leftX;
rightX = _rightX;
topY = _topY;
bottomY = _bottomY;
isAppt = _isAppt;
time = _time;
init();
}
private void init(){
rectPaint = new Paint();
if(isAppt){
rectPaint.setARGB(144, 217, 131, 121);
rectPaint.setStyle(Style.FILL);
}
else{
rectPaint.setARGB(0, 0, 0, 0);
rectPaint.setStyle(Style.FILL);
}
if(leftX > rightX || topY > bottomY)
Toast.makeText(context, "Incorrect", Toast.LENGTH_SHORT).show();
rectangle = new Rect(leftX, topY, rightX, bottomY);
int height = bottomY;
int width = rightX - leftX;
MyUtility.LogD_Common("Height = " + height + ", Width = " + width);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height);
params.leftMargin = leftX;
params.rightMargin = 10;
setLayoutParams(params);
}
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
canvas.drawRect(rectangle, rectPaint);
if(isAppt){
rectPaint.setColor(Color.RED);
rectPaint.setStrokeWidth(2);
rectPaint.setStyle(Style.STROKE);
canvas.drawRect(rectangle, rectPaint);
}
}
}
右の境界線が表示されない原因は何ですか?