Hey, I'm new and learning Android by making an app as a project for my school. I've run into a problem where it's not working on smaller QVGA devices.开发者_开发技巧 It's cut off at the bottom. I have read the official Dev guide about supporting different screen sizes and guess I don't fully understand what's going on.
The code I have uses a relative layout and (dip) units only.
The layout looks great on the medium HVGA phone and make use of the space. Of course it scales up to large screens fine with a little extra space and my understanding would be that it would get smaller fit and work on small devices. Can it not look exactly the same relative to the phones screen?
Here are some screen shots of the the QVGA and HVGA emulation.
Note: the low-quality/incorrect images are just place holders for now. http://i19.photobucket.com/albums/b183/CraZboyz/Mischosting/CDQVGA.jpg
One possible fix for this, since it seems to be alright side-to-side, is to implement a ScrollView. It will allow users to scroll down on smaller phones, and won't affect the larger screens that don't need to scroll.
If you want any scaling to happen for screen size (not for pixel density), you'll need to do it yourself. If you put a new xml file in res\layout-small, you can make any necessary adjustments in that file without changing the layout behavior on medium, large, or xlarge screens.
That change could be adding a ScrollView, as Brandon suggested. It could be a set of more detailed changes, such as scaling down the logo, using less padding and margins, using smaller font sizes, and so on. If you change the logo size, it could be done either by changing the size of the ImageView or by providing a smaller logo in res\drawable-small-ldpi, res\drawable-small-mdpi, etc.
The reason the layout isn't scaling down to fit the smaller screen is that it isn't supposed to scale down for screen size. In general, each component scales so it should be about the same physical size on any device, which means it will scale for pixel density but not for size. A button, for example, might scale in number of pixels between an ldpi device and an mdpi one, but it won't scale in inches. If it did scale in physical size, a small but usable button would become an annoyance that users can't reliably tap.
Yes, your emulator AVD images seem to have different button, image, and font sizes, but that's a sort of illusion. The apparent size difference in your AVDs comes from different pixel densities. If you use the option to scale display to to real size (or create an AVD with small screen size but mdpi density), you should see components that are about the same size in both AVDs.
精彩评论