Reputation: 271
Is it possible to to have 2 or more shapes in a single drawable?
I'm trying to create something like this:
I have one drawable token.xml which creates one of the rectangles with black color and a white border:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- view background color -->
<solid
android:color="@android:color/black" >
</solid>
<!-- view border color and width -->
<stroke
android:width="1dp"
android:color="@android:color/white" >
</stroke>
any idea?
Upvotes: 1
Views: 1681
Reputation: 2618
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="0dp" android:left="0dp" android:bottom="0dp" android:right="0dp">
<shape android:shape="rectangle">
<size android:width="9dp"
android:height="9dp"/>
<solid android:color="#f000"/>
</shape>
</item>
<item android:top="1dp" android:left="1dp" android:bottom="5dp" android:right="5dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#f00"/>
</shape>
</item>
<item android:top="1dp" android:left="5dp" android:bottom="5dp" android:right="1dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#0f0"/>
</shape>
</item>
<item android:top="5dp" android:left="1dp" android:bottom="1dp" android:right="5dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#0f0"/>
</shape>
</item>
<item android:top="5dp" android:left="5dp" android:bottom="1dp" android:right="1dp">
<shape android:shape="rectangle">
<size android:width="3dp"
android:height="3dp"/>
<solid android:color="#f00"/>
</shape>
</item>
</layer-list>
Upvotes: 2