I'm trying to fit (center and inside) 2 kind of images obtained from web services in a Big Picture styled Notification. One kind is 97px*150px sized and the other 300px*100px.
As I checked the image must fit 256dp tall max height to fit on Jelly Bean's Big Picture notification visual area, so I expected that I can call the matrix scales availables on ImageView (fitXT, centerInside, etc) but i'm surprised that no scaling method behavior is available to configure and the bitmap is always center-cropped wich by the way is worst default matrix behavior I would selected for default because images always are cutted in some way. A center inside behavior for default it would be better, I think.
So, this leaves me room for this posibilities:
- Pre-scale images using some sort of pixels to dp method. This method must also has to respect aspect ratio. After that use that new picture against Notification Builder, wich (I expect) will respect the iomages because no out of bounds behavior will happen.
- Create my own RemoteView to use ImageView and gain access to scale matrix behaviors.
- File a new feature request to Google :)
- File a bug request to Google :)
Which option do you think or know as the best? Is there any other option that am I could be missing?
EDIT: I've tested several methods to matrix scale the images with success but the center-crop is always there by default to break and cut my images making it imposible to use.
I will give a try now to RemoteView method.
I also filed the issue 58318 for this, trying to make life easier for future devs trying to accomplish this task: https://code.google.com/p/android/issues/detail?id=58318
The only solution is to create my own RemoteView as follows:
First, a custom layout:
And the RemoteView implementation:
Where myNotification is your notification builder and randomInt is my own implementation to no overlap notifications (check if this is not your need to replace notifications or generate several).
And that's it. Maybe is a little dirty but it works. I'll leave the bug open to Google and if I receive some response i'll update this.