Resizing image for low-res screen
Among other things, my app displays photos in an ImageView in a popup Dialog. These images come out of a database that is created on the user's PC. Before storing them in the database, I resize them for max dimensions of 320x320 pixels.
So, in almost all cases, on the Android device I simply display the photos at their "natural" dimension, which fits nicely on almost all screens. However, I have at least one customer with an HTC Wildfire which, even though its screen is 3.2", has only QVGA dimensions (240x320). With my current code, the photos do seem to be resized by the system to display within the screen boundaries, but the rest of the views in the dialog (caption, buttons, etc.) get "pushed off the screen" and are not visible or usable.
Obviously I need to handle this case by setting some specific dimensions on the ImageView when running on a QVG开发者_如何转开发A device, but what is the best approach? Should I use DisplayMetrics to discover the dimensions and adjust accordingly? This would work, but seems like it might be too low-level of an approach. Could I put dimension the image in the XML in some way using "dips"?
Everything you need to know is here: http://developer.android.com/guide/practices/screens_support.html
It sounds like you are specifying dimensions in px instead of dip in your layout files.
精彩评论