Optimizing graphical content for Android devices
One commonly overlooked problem that can arise in Android app development is optimizing the graphics to look great across all ranges of devices.
There are many different Android devices and since there are no particular rules on what size the screen should be, what the resolution should be, or the aspect ratio of screens, creating a good looking app can quickly become a daunting task. Throw tablets into the mix and one could quickly foresee a headache in their future.
To help grasp the seriousness of the situation, imagine that you have assigned a background image to fit perfectly to a certain device. On another device with a different aspect ratio and resolution, the image will fit much differently, can could look skewed, distorted, stretched, or cause memory issues because the device was expecting a much smaller image knowing it has a much smaller resolution.
Thankfully Android does provide solutions to these issues. Take a look at the specs of some popular android devices.
|Device||Screen Size (inches)||Resolution||Pixels Per Inch||Aspect Ratio||Density Category(DPI)|
|Galaxy Note||5.3||800×1280||285||5:8 (10:16)||xhdpi|
|Galaxy Note II||5.55||720×1280||267||9:16||xhdpi|
|Galaxy S II (I9100)||4.27||480×800||219||3:5||hdpi|
|Galaxy S III (I9300)||4.8||720×1280||306||9:16||xhdpi|
|Galaxy S4 (I9500)||5||1080×1920||441||9:16||xxhdpi|
|Galaxy Note 10.1||10.1||1280×800||149||8:5 (16:10)|
|Galaxy Note 10.1 (2014 Edition)||10.1||2560×1600||299||8:5 (16:10)||xhdpi|
Take Notice of all the different Screen Sizes, Resolutions, and Aspect Ratios. This is a designer’s nightmare! There must be a way to deal with this, and there is.
This is where screen sizes and densities (which can be found by the ppi (pixels per inch)) that android has broken into Density Categories come into play.
Much like iOS lets you define a ‘normal’ and ‘retina’ resource for images, Android allows you to define different images and layouts for different screen sizes and density categories. Each category is designed to hold the image that should be shown on a device with a density that falls into that category. However since large tablet screens can have a higher resolution and a lower ppi because of their large screen size, the density categories can be broken down further into a basic screen size.
First the default or ‘phone’ set of resources, can be defined and placed into the following categories
Tablets of approx. 7″ can have their resources defined and placed into these following
Tablets of approx. 10″ can have their resources defined and placed into these following
|suggested icon size||36×36||48×48||72×72||96×96||144×144||192×192|
|approx pixel density||120||160||240||320||480||640|
Multiple APK support is a feature on Google Play that allows you to publish different APKs for your application that are each targeted to different device configurations. Each APK is a complete and independent version of your application, but they share the same application listing on Google Play and must share the same package name and be signed with the same release key. This feature is useful for cases in which your application cannot reach all desired devices with a single APK.