Default display unit px or dp?

by Markus » Tue, 13 Oct 2009 05:17:00 GMT

Sponsored Links
 I always thought the default display unit would be pixels.

But when I run my application on WVGA800 in the emulator the lines are
five pixels wide even though I called Paint.setStrokeWidth(3). The
same seems to happen with Drawable.setBounds(); the value I provide
gets multiplied by 1.5 internally.

If that's the case, how can I specify pixels instead of dips if I want

Can someone clarify this?


Default display unit px or dp?

by Romain Guy » Tue, 13 Oct 2009 05:20:09 GMT

 The Java APIs work only with pixels. Your app is probably running in
compatibility mode.

Romain Guy
Android framework engineer

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


Sponsored Links

Default display unit px or dp?

by Markus » Tue, 13 Oct 2009 06:08:20 GMT

 Specifying android:minSdkVersion="4" in the android manifest did the



Other Threads

1. "message size limit reached" when try to record audio

Hi, I met this problem in some mobile. I invoke the system recorder
with normal intent, and file type as audio files. It had no problem
before. But recently, some users report this problem. I don't know
whether it's because of new version of android.

In these mobile, starting the sound record doesn't have these problem,
but in my application, this problem occurs. I start the record with:

myIntent.putExtra("return-data", false);
startActivityForResult(Intent.createChooser(myIntent, ""),

Can any one help? Thanks!


2. Will no longer support Android 1.5

I just warned my users that support for Android 1.5 will go away after
April 1st.  The share of 1.5 is < 5% now and dropping.

Between not supporting multiple resolutions, wonky RelativeLayout and
old style Contacts provider, it's time to say goodbye to 1.5.

Would love to hear people's opinion on this decision?


3. Webview window.opener returns undefined

4. stagefright build options for gingerbread on omap3

5. Implement Service in one application and access in another application

6. error in my Android app

7. SIGSTKFLT from DefaultHttpClient