Issue
I have read the documentation and some questions but I can't find any answer. This is my first full-blown app and I want it to at least render properly on different screen sizes so I used dp for units and sp for textviews. I have tried it on different devices and different avd's. I have observed that that on most devices, screen size is directly proportional to density. (small screen has ldpi, normal screen has mdpi, large screen has hdpi, xlarge screen has xhdpi) With this, my default layout renders on devices that follows this trend. However, there are devices that doesn't follow this trend (e.g. Samsung Galaxy Tab which has, if I'm not mistaken, large-mdpi), so when I tried my layout, the splash screen (Yes, I know splash screens are annoying and not recommended) is pixelated, and the texts are small.
What I want to happen is that the splash screen would depend on the screen size and the text sizes would depend on the screensize & density. How do I achieve this? Thanks.
Solution
Check out this page: Android Devices
It shows the many devices and what their corresponding stats are. Then you need to decide how to best target a device that is not displaying things correctly.
I think the best approach is with different values folders, where you can make different folders based on API level (like values-v11 for all devices using API 11 or less) or by screen size (like values-small thru values-xlarge). Then you create different styles.xml, dimens.xml, and even colors.xml.
In the layouts, you give each widget a style that uses different dimens or you can just put the dimension values in the styles, or you can set the values from the dimens.xml file in the layout file.
You're only supposed to use dpi qualifiers on the drawable folders (like drawable-hdpi), since bitmaps don't scale with dpi as well as fonts and other drawables.
As for different layout folders, I think you should limit them to portrait versus landscape, where the position of the widgets varies.
The Galaxy Tab is a tablet with 1024 X 600 screen size. This is where you want to have a different values folder (values-xlarge). You may also want to define special styles for it using dimensions that work for a tablet. You put the styles.xml, dimens.xml files for it in the values-xlarge folder.
So, yea a tablet is going to really stretch any bitmap you would use for a background. In this case you could have a different drawable for it.
Answered By - Rick Falck
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.