Reusing parts of drawable on Android
<p>I'm preparing drawables for my application. I've got a lot of radiobuttons, which are being displayed as images with optional frame (when checked). One drawable looks like the following:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:state_checked="true"&gt;
        &lt;layer-list&gt;
            &lt;item&gt;
                &lt;shape android:shape="rectangle"&gt;
                    &lt;solid android:color="@color/colorPrimary" /&gt;
                &lt;/shape&gt;
            &lt;/item&gt;

            &lt;item&gt;
                &lt;inset android:insetTop="@dimen/selectionBorderSize"
                    android:insetLeft="@dimen/selectionBorderSize"
                    android:insetRight="@dimen/selectionBorderSize"
                    android:insetBottom="@dimen/selectionBorderSize"&gt;
                    &lt;layer-list&gt;
                        &lt;item&gt;
                            &lt;shape android:shape="rectangle"&gt;
                                &lt;solid android:color="#ffffff"&gt;&lt;/solid&gt;
                            &lt;/shape&gt;
                        &lt;/item&gt;
                        &lt;item&gt;
                            &lt;bitmap android:src="@drawable/sharp7" &gt;
                                &lt;padding android:bottom="@dimen/selectionBorderSize"
                                    android:top="@dimen/selectionBorderSize"
                                    android:left="@dimen/selectionBorderSize"
                                    android:right="@dimen/selectionBorderSize" /&gt;
                            &lt;/bitmap&gt;
                        &lt;/item&gt;
                    &lt;/layer-list&gt;
                &lt;/inset&gt;
            &lt;/item&gt;
        &lt;/layer-list&gt;
    &lt;/item&gt;

    &lt;item android:state_checked="false"&gt;
        &lt;layer-list&gt;
            &lt;item&gt;
                &lt;shape android:shape="rectangle"&gt;
                    &lt;solid android:color="#ffffff" /&gt;
                &lt;/shape&gt;
            &lt;/item&gt;

            &lt;item&gt;
                &lt;inset android:insetTop="@dimen/selectionBorderSize"
                    android:insetLeft="@dimen/selectionBorderSize"
                    android:insetRight="@dimen/selectionBorderSize"
                    android:insetBottom="@dimen/selectionBorderSize"&gt;
                    &lt;layer-list&gt;
                        &lt;item&gt;
                            &lt;shape android:shape="rectangle"&gt;
                                &lt;solid android:color="#ffffff"&gt;&lt;/solid&gt;
                            &lt;/shape&gt;
                        &lt;/item&gt;
                        &lt;item&gt;
                            &lt;bitmap android:src="@drawable/sharp7" &gt;
                                &lt;padding android:bottom="@dimen/selectionBorderSize"
                                    android:top="@dimen/selectionBorderSize"
                                    android:left="@dimen/selectionBorderSize"
                                    android:right="@dimen/selectionBorderSize" /&gt;
                            &lt;/bitmap&gt;
                        &lt;/item&gt;
                    &lt;/layer-list&gt;
                &lt;/inset&gt;
            &lt;/item&gt;
        &lt;/layer-list&gt;
    &lt;/item&gt;

    &lt;item&gt;
        &lt;shape android:shape="rectangle"&gt;
            &lt;solid android:color="#ffffff" /&gt;
        &lt;/shape&gt;
    &lt;/item&gt;
&lt;/selector&gt;
</code></pre>

<p>Another one:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:state_checked="true"&gt;
        &lt;layer-list&gt;
            &lt;item&gt;
                &lt;shape android:shape="rectangle"&gt;
                    &lt;solid android:color="@color/colorPrimary" /&gt;
                &lt;/shape&gt;
            &lt;/item&gt;

            &lt;item&gt;
                &lt;inset android:insetTop="@dimen/selectionBorderSize"
                    android:insetLeft="@dimen/selectionBorderSize"
                    android:insetRight="@dimen/selectionBorderSize"
                    android:insetBottom="@dimen/selectionBorderSize"&gt;
                    &lt;layer-list&gt;
                        &lt;item&gt;
                            &lt;shape android:shape="rectangle"&gt;
                                &lt;solid android:color="#ffffff"&gt;&lt;/solid&gt;
                            &lt;/shape&gt;
                        &lt;/item&gt;
                        &lt;item&gt;
                            &lt;bitmap android:src="@drawable/sharp6" &gt;
                                &lt;padding android:bottom="@dimen/selectionBorderSize"
                                    android:top="@dimen/selectionBorderSize"
                                    android:left="@dimen/selectionBorderSize"
                                    android:right="@dimen/selectionBorderSize" /&gt;
                            &lt;/bitmap&gt;
                        &lt;/item&gt;
                    &lt;/layer-list&gt;
                &lt;/inset&gt;
            &lt;/item&gt;
        &lt;/layer-list&gt;
    &lt;/item&gt;

    &lt;item android:state_checked="false"&gt;
        &lt;layer-list&gt;
            &lt;item&gt;
                &lt;shape android:shape="rectangle"&gt;
                    &lt;solid android:color="#ffffff" /&gt;
                &lt;/shape&gt;
            &lt;/item&gt;

            &lt;item&gt;
                &lt;inset android:insetTop="@dimen/selectionBorderSize"
                    android:insetLeft="@dimen/selectionBorderSize"
                    android:insetRight="@dimen/selectionBorderSize"
                    android:insetBottom="@dimen/selectionBorderSize"&gt;
                    &lt;layer-list&gt;
                        &lt;item&gt;
                            &lt;shape android:shape="rectangle"&gt;
                                &lt;solid android:color="#ffffff"&gt;&lt;/solid&gt;
                            &lt;/shape&gt;
                        &lt;/item&gt;
                        &lt;item&gt;
                            &lt;bitmap android:src="@drawable/sharp6" &gt;
                                &lt;padding android:bottom="@dimen/selectionBorderSize"
                                    android:top="@dimen/selectionBorderSize"
                                    android:left="@dimen/selectionBorderSize"
                                    android:right="@dimen/selectionBorderSize" /&gt;
                            &lt;/bitmap&gt;
                        &lt;/item&gt;
                    &lt;/layer-list&gt;
                &lt;/inset&gt;
            &lt;/item&gt;
        &lt;/layer-list&gt;
    &lt;/item&gt;

    &lt;item&gt;
        &lt;shape android:shape="rectangle"&gt;
            &lt;solid android:color="#ffffff" /&gt;
        &lt;/shape&gt;
    &lt;/item&gt;
&lt;/selector&gt;
</code></pre>

<p>If you don't wanna play "find 2 differences", the only thing that changes is the image in <code>&lt;bitmap&gt;</code> tag.</p>

<p>I'm feeling whole WET<sup>1</sup> here. Is there a way to reuse part of this drawable?</p>

<p><sup>1</sup> WET, eg. not <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a></p>