Querying applicationScale in Android

20 Jul
2010

If you let Android auto-scale your app (this is what happens when you set anyDensity=false in AndroidManifest.xml) for different densities and resolutions, debugging it can be painful because you can’t confirm or query the application scale that Android chooses. While poking around this week on a particularly tricky bug in Titanium Mobile for Android, I came up with the following snippet that gives me the current applicationScale from the internal CompatibilityInfo class:

All you need is a View, and you can get your app’s scale. Keep in mind this API is not official, so it could change in future versions of Android.

Comment Form

top