DisplayMetrics issue on Android1.6 SDK

by lianwei » Sat, 19 Sep 2009 18:02:08 GMT

Sponsored Links
 I got a issue with DisplayMetrics.

  DisplayMetrics dm = new DisplayMetrics();
  Log.d("TEST", dm.widthPixels + "x" + dm.heightPixels);

If I do not specify the <uses-sdk android:minSdkVersion="4" /> or
<supports-screens android:anyDensity="true"></supports-screens>, then
the value of dm.widthPixels and heightPixels is wrong on QVGA and WVGA
screen. e.g. on QVGA, the return value is 320x427.

If this is a bug on Android1.6 SDK?

For chinese users, please see  http://easyandroid.com/bbs/viewthread.php?tid=19 

DisplayMetrics issue on Android1.6 SDK

by Dianne Hackborn » Sun, 20 Sep 2009 01:31:47 GMT

 That is intentional.  If you haven't said you support other densities than
the framework runs you in a compatibility mode to make it look like you are
on a medium density device.  By saying that you work with SDK 4, you are
also implying that you understand how to deal with densities.

Dianne Hackborn
Android framework engineer

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


Sponsored Links

Other Threads

1. What thread is ViewRoot runs


Can you please tell me what is the read which ViewRoot runs?
Is it the same thread as the Activity on the top of the screen? Or it
is a system thread?

If it is a system thread, does it responsible calling the onDraw of the Activty?

Thank you.


2. How to create home screen short cut?

I am trying this code but its not working ....

                Intent shortcutIntent = new Intent
                shortcutIntent.setClassName(this, this.getClass

                Intent intent = new Intent();
                intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "hello");
                Parcelable iconResource =
                        NoteView.this,  R.drawable.short_icon);



3. starting two emulators and building apps for one or the other with new 1.5 SDK

4. How can I test the video recording functionality in the new emulator

5. ContentObserver triggers repeatedly for contacts

6. starting two emulators and building apps for one or the other with new 1.5 SDK

7. starting two emulators and building apps for one or the other with new 1.5 SDK