Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rectangle inside another rectangle

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.

drawable

like image 689
Zheka Avatar asked Sep 24 '11 17:09

Zheka


People also ask

How do you know if a point is inside a rectangle?

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.


1 Answers

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>
like image 128
user Avatar answered Sep 19 '22 02:09

user