I have a LayerDrawable, which should display 5 Bitmaps. 1 background and 4 Icons (which can be different for every LayerDrawable) like a Grid. Unfortunately these Icons don't have the same width than height. My Problem is to resize them, while keeping their ratio and place them inside their Position (1-4 Icons, 5 background):
==================
| | | |
| 1 | | 2 |
|------.5 .------|
|------. .------|
| 3 | | 4 |
| | | |
==================
If I resize these Bitmaps, give them Gravity.CENTER
they won't fit anymore inside the Bounds of the Background Rectangle. If I leave Gravity.CENTER
they seem to get rescaled as soon as I call layerDrawable.setLayerInset(numlayer, left, top, right, bottom)
.
What is the right way to do it? How can I keep their ratio while placing them correctly?
What I also couldn't understand so far is why getIntrinsicWidth/Height from BitmapDrawable is returning something else (smaller) than getWidth/Height from original Bitmap.
What I tried:
1. Getting them from XML, putting a 'dummy-drawable' inside and replace it with result described above.
2. Create LayerDrawable inside my Program passing all drawables inside. It seems that setLayerInset has no affect, or I only see the Background (which was Element 0 inside my Drawable Array)
3. Extending LayerDrawable and try to keep track on anything myself without reasonable results