Is it possible to create drawable from xml like on the picture? The first rectangle contains a second rectangle.
If yes, please explain to me how.
In any case, for any convex polygon (including rectangle) the test is very simple: check each edge of the polygon, assuming each edge is oriented in counterclockwise direction, and test whether the point lies to the left of the edge (in the left-hand half-plane). If all edges pass the test - the point is inside.
If you want simple rectangles you could use a LayerList with two shapes as content:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#a1a1a1" />
</shape>
</item>
<item android:top="5dp" android:right="5dp" android:bottom="5dp"
android:left="5dp">
<shape android:shape="rectangle">
<solid android:color="#f1f1f1" />
</shape>
</item>
</layer-list>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With