How can I apply an alpha mask to an Android drawable?
<p>In my application, I need to change the background color of a button in response to certain events. That works fine by setting creating a drawable, setting its paint and using that drawable as the button background:</p>

<pre><code>    ShapeDrawable drawable = new ShapeDrawable(roundRectShape);
    drawable.getPaint().setColor(color);
    b.setBackground(drawable);
</code></pre>

<p>Now, I want to overlay an alpha mask onto that drawable, creating a "striped" button. Here's how it should look like for a blue and a black button (assuming white as the background color, but these sections should really be 100% transparent):</p>

<p><a href="https://i.stack.imgur.com/XM9Jn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XM9Jn.png" alt="enter image description here"></a></p>

<p>I made this alpha mask in Inkscape, and successfully imported it as a vector asset. I might need to convert it to a bitmap of sorts, but I'm not sure.</p>

<p>I've read a bunch of articles and SO questions mentioning PorterDuff matrices to apply, but haven't been able to translate these into solving my current problem.</p>

<p>Anyone know how to do this?</p>

<hr>

<p>Here's another visualization, hopefully making things clearer. The background color of the parent view of the button is pale pink here, and the button border is outlined in red (but should really be invisible in the end product):</p>

<p><a href="https://i.stack.imgur.com/PI5eR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PI5eR.png" alt="enter image description here"></a></p>