Android - Rounded Rectangle in Rounded Rectangle

I am currently developing a login page, and I ran into the problem of using rounded rectangles. My current layout looks something like this:

enter image description here

This is a rounded rectangle containing a smaller rounded rectangle.

As you can see, the right edges of both rectangles seem to merge. However, I want to maintain a constant distance between the borders of the two rectangles for a clearer look. Is there any way to do this?

+4
source share
3 answers

In EditText you can try layout_marginRight in XML.

+2
source

If your outer rectangle is outerRect and already contains the coordinates, you can set the borders of the inner rectangle relative to the border of outerRect .

 Rect innnerRect = new Rect(outerRect.left+5, outerRect.top+5, outerRect.right-5, outerRect.bottom-5); 

Update:

You can also make the image available for 9 patches. Define the middle of the inner rectangular region as expandable.

+1
source

To do this, the rectangles must have the same radius at each corner.

If the corners of the outer rectangle have a radius of 10dp, the inner rectangle should also have a radius of 10dp.

Edit:

You also need to have the same indentation / margin at the top, bottom and right of the inner rectangle. Check your fields and gaskets to add the same value.

+1
source

Source: https://habr.com/ru/post/1413415/


All Articles