I try to create a stroke for my view and it work well if the left and top is 0.
After I change the left
rect, the left edge stroke is bigger than normal.
Example, I set the left
to 10
public class SimpleView extends View {
Paint paint = new Paint();
RectF bodyRect = new RectF();
...
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
bodyRect = new RectF(10, 0, getWidth(), getHeight());
paint.setColor(Color.WHITE);
paint.setStrokeWidth(20);
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(bodyRect,paint);
}
}
xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
...
android:background="#000">
<...SimpleView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_margin="50dp"
android:background="#f00" />
</LinearLayout>
the left stroke is bigger
If I use the
bodyRect = new RectF(0, 0, getWidth(), getHeight());
Any help would be great appreciated.