Issue
I have a xxhdpi xml file that I need to downscale for xhdpi and mhdpi.
The dp sizes in the XXHDPI file are perfect, but I have xhdpi and mhdpi devices that are displaying inaccurately.
I understand sizing for bitmap/PNG graphics. That is not my problem.
My problem is trying to scale elements within the UI (picture questions and answers with background fills and/or font especially sizes). I'm being advised to go back and remeasure each element in Photoshop? This cannot be right, surely I can apply a mathematical formula to this problem?
Also how can I account for the strange sizes of todays XHDPI marketplace?
For example:
xxhdpi: < dimen name="standard_button_height">40dp< dimen >
xhdpi: < dimen name="standard_button_height">?dp< dimen >
Solution
If I understand you correctly you want your app to look identically scaled across all devices (meaning you don't wish to take advantage of the extra space on tablets and instead just blow everything up to be proportional across the board). If that's not correct, please elaborate further.
However, to solve the above problem...
What you need to focus on is not the xxhdpi vs. xhdpi here but rather the DP of the target device. The vast majority of Android devices fall into two classes. Those that are ~360x640dp and those that are ~800x1280dp (when held in portrait). The latter is the xlarge class (tablets).
So, you'll want to create a directory called res/values-xlarge and in that folder you'll have a dimens.xml in which you'll scale all your DP widths by 2.22 (800/360) and all your DP heights by 2 (1280/640). So your 40dp tall button will need to be 80dp.
This is not a perfect gambit because some devices use some of the screen real estate for non hardware keys (while others have hardware keys and give you the entire screen to utilize).
Answered By - Yevgeny Simkin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.