Android display chaos: a function, not a bug

Phones come in a lot of sizes, and Android (on the two Nexus designs here) is developed to span the range.
(Credit:
cellphone-dimension.com)
A single of the pesky fragmentation troubles
Android programmers ought to be concerned about is various screen sizes.
With resolution modifying from one phone to one more, programmers have to figure out precisely how much space they can devote to icons, photographs, video game backgrounds, dialog boxes. But, Google argues, paying the value upfront pays programmers back in the long run–and can help them avoid the fixed-resolution troubles that afflicted Palm.
Certainly, even before the initial Android mobile phone hit the market place, Google had set on an method developed to accommodate not just various pixel resolutions, but also pixel densities–the number of pixels per inch. Android framework engineer Diane Hackborn described the company’s philosophy in a Google+ post yesterday:
Significantly of the determination for this came from encounter at Palm/PalmSource. Palm devices traditionally had a 160×160 screen. Later in their lifestyle, Sony introduced a 320×320 display this worked quite effectively by just doubling the coordinates supplied by the application so (unless of course employing new APIs) it nevertheless believed it was drawing on a 160×160 display but the OS would convert people and take benefit of the higher-resolution display to present sharper text and drawn shapes.
This method grew to become problematic in PalmOS later on, even so, when it needed to ship QVGA [320x240] screens. These have been cheaper to create since they have been utilised in numerous other devices by putting the handwriting spot at the bottom of the display you could even now have the anticipated square location for the app. However their density was halfway between 160×160 an 320×320, giving a scaling element of 1.five, and here the problems appeared.
Scaling up object dimensions by a one.5x meant, for example, that “your great reliable lines now get a variety of gray smudges on them dependent on how they align with the actual screen pixels,” she stated.
To handle Android’s problems with screen sizes and resolution, the operating method utilizes an idea called the density-independent pixel, variously abbreviated dp or dip.
Android’s approach to display resolution can be baffling, and Android comes with a selection of layout equipment. After you master them, “it’s zero-work-straightforward to make layouts that immediately resize for portrait/landscape gadget orientations and varying screen sizes,” stated Meridian Apps programmer Nick Farina in a blog post.
“If you specify, in your application, a button with a width of 100 pixels, it will search at great deal smaller on the 640×480 device than on the 320×480 gadget. Now, if you specify the width of the button to be 100 dip [density-independent pixels], the button will appear to have exactly the identical size on the two devices,” explained Android engineer Romain Guy in a mailing list post.

Pixel-per-inch densities differ, so Android programmers need to consist of graphic elements in multiple sizes.
(Credit:
Google)
The Android approach could theoretically deal with any pixel-per-inch density. But for convenience, Google set up what Hackborn named “a couple of main buckets…ldpi (approx 120dpi), mdpi (160 dpi), hdpi (240 dpi), and xhdpi (320 dpi).” To deal with the method, Google exhorts programmers, “Provide assets for distinct display densities (DPI) to ensure that your app looks fantastic on any gadget.”
So there is upfront operate for coders and graphic designers. But the outcome, she explained, is that software package adapted reasonably properly to the arrival of the Galaxy Nexus and its 316dpi, 1280×720 display.
“Android and its applications were in a position to fairly much run on it as-is,” Hackborn explained.
So yes, the Android method is flexible. It had to be, of course: from the start, Google envisioned Android as an operating method for many makers.

Android is vibrant, but it is messy, also.
(Credit:
Stephen Shankland/CNET)
Items operate really in a different way in the globe of the
iPhone, exactly where Apple is in firm management.
With iOS, programmers shell out more interest to each and every pixel. When the
iPhone four arrived, the screen resolution doubled exactly from 480×320 to 960×640, producing the pixel-doubling math straightforward. Several signs point to the subsequent-generation iPad taking the identical technique, doubling the very first iPads’ 1024×768 resolution to two,048×1,536 pixels.
Apple’s strategy amazed Tim Bray, an Android developer evangelist for Google, when he recognized how it worked from Farina’s explanation.
“I initially shook my head in disbelief at all the minor bits of tough-coded arithmetic, like y += 7 and MARGIN – 30. Obviously this logic is not resilient in the face of a various-shaped display. But I bet it is quick,” Bray said. He additional:
It is plausible, as Nick Farina implies, that iOS’ fixed-dimensions display model is partly accountable for the astonishingly-quick functionality Apple wrings out of the underlying hardware.
And I’m not even saying that Apple’s choice here is incorrect. The trade-off, if I comprehend it correctly, is form-factor flexibility for functionality and simplicity, and so far that’s been functioning out fairly nicely for them.
Report supply
CM9 is now available for the original Galaxy Tab Will We Eventually See the Release of the Samsung Epic 2?



