Why is the rectangle corner radius not maintained for different stroke width?

Viewed 24

Is there a way to draw a rectangle with corners which do not grow with the stroke width?

In the code below, you can see how the 2nd rectangle shape in the code with the blue stroke and stroke width="50dp", renders the same corners="5dp" much bigger than the 1st rectangle in the code (filled in black):

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <shape android:shape="rectangle">
      <solid android:color="#000000" />
      <corners android:radius="5dp"/>
    </shape>
  </item>
  <item>
    <shape android:shape="rectangle">
      <corners android:radius="5dp"/>
      <solid android:color="#FF0000" />
      <stroke
          android:width="50dp"
          android:color="#0000FF" />
    </shape>
  </item>
</layer-list>

enter image description here

I don't necessarily want to use a layer list or a rectangle shape, any way to draw a rectangle with the exact corner size and border would do.

0 Answers
Related