Tuesday, December 18, 2012

Handle XXHDPI in your Android apps

After Google mentioned the xxhdpi in their online document and first batch of mobile devices supporting this resolution rolled out to the market, developers may need to know how to handle this  resolution in the apps.

HTC Butterfly (Japan)




HTC Butterfly (China)


HTC DNA (Verizon Wireless)



Since this screen resolution parameter is new, if your apps have not handled it, your apps may not be visible on devices when users use Google Play store to search apps.

To solve the issue of app not visible on devices with xxhdpi resolution, developers need to read the documentation provided by Google. Please check the best practice Google provides at http://developer.android.com/guide/practices/screens_support.html ,

It is said that the best practice is to use the <supports-screens > element in the manifest file of the application, and developers can set anyDensity is true. This will solve most of the cases. There are some cases that this solution would not work. 

As you may notice that there is another element, <compatible-screens>,  mentioned in Google's online document.  Some apps on the market are using this element/tag in the manifest files to resolve the screen resolution issue, and even use these 2 tags/elements in the same time. If you create a simple apk with various combinations of these two tags in the manifest file, it could be easily found that some of the definitions inside of the <compatible-screens> would override the definitions inside of the <supports-screens> tag.

It is mentioned that if you have to use <compatible-screens> in the manifest file to filter out your apps for devices with certain screen resolutions or sizes, you will need to add one more value inside of this tag:
        <screen android:screenSize="normal" android:screenDensity="480" />
for the xxhdpi. The other definition you may also add is tvdpi, its value is 213, which is for devices like Nexus 7.

After modifying the manifest file, you may also consider adding resources, such as drawables, layout styles, for the xxhdpi.

No comments: