I have several monochrome bitmaps that I use. I discovered that I can change the color in my drawables.xml file simply by specifying a different palette, as follows:
<drawables>
<bitmap id="BlackArrowUp" filename="Black.Up.85x85.png" dithering="none">
<palette>
<color>000000</color>
</palette>
</bitmap>
<bitmap id="WhiteArrowUp" filename="Black.Up.85x85.png" dithering="none">
<palette>
<color>FFFFFF</color>
</palette>
</bitmap>
</drawables>
That works great (in the simulator at least - haven't tried it on an actual device yet.) But it got me thinking - can I do the same thing without having to define all the "white" images in the XML file? That is, can I map the palette when I go to draw the image?
I tried creating a BufferedBitmap with a palette of [ COLOR_RED, COLOR_TRANSPARENT ]. But when I attempt to draw the "black" image, it crashes and I get the error:
Error: Unhandled Exception
Exception: Bitmap source color cannot be found in the target palette
Has anyone tried this, or something similar, and gotten it to work? It's not that big of a deal for me to just create multiple resources in the drawables.xml file. But it would be "cleaner" if I could just have one set of images, and change the color when I go to draw them. Thanks!!