Kostya,

I'll have to keep this in mind.  I guess the hardware manufacturers decide 
if they want to follow the rules fully or not in a lot of cases. You would 
think that this would be one of the things that manufacturers would do 
correctly since it's so easy to get right from their perspective.

Niels,

I'm thinking the calibration mode would be necessary if some devices aren't 
reporting their dpi correctly. Since it seems you are looking for the 
ability to show real world size of an object on a phone, you could use a 
common object and have the user size the picture to the object.  Maybe use a 
penny or a dime? Have the user set it on a picture on the phone and use 
plus/minus buttons to match the picture on the phone to the real thing?

Steven
Studio LFP
http://www.studio-lfp.com


On Friday, October 7, 2011 8:09:37 AM UTC-5, Kostya Vasilyev wrote:
>
> The quantized density value (160/240 etc) is used by resource loading code, 
> and so can be expected to be there. Some devices deliberately use a value 
> that is not the closest match to the actual physical density, but it's the 
> same for all applications on the device.
>
> The xdpi and ydpi can sometimes be completely nonsensical.
>
> If you need exact actual physical screen density (e.g. for a ruler type 
> application), consider providing a calibration mode in your application.
>
> --
> Kostya Vasilyev
> 07.10.2011 16:50 пользователь "niels" <nioe...@googlemail.com> написал:
>
>> Thanks for the info. As result of another discussion I already had a
>> look at the DisplayMetrics class. They clearly state there, that I
>> can't rely on dip because it's just based on the default density
>> (160dpi, 240dpi, 320dpi, etc.) which is nearest to the device's real
>> density. So this (official) docu is simply wrong:
>> http://developer.android.com/guide/practices/screens_support.html
>>
>> So at least theory allows correct scaling, if I don't use XML (which
>> from my point of view is a design error). But in practice HTC
>> Sensation unluckily returns crap when trying to read ot X and Y DPI.
>> Both values are around 160 whereas they should be something around
>> 256.
>>
>> Regards,
>> Niels
>>
>> On Oct 6, 4:54 pm, Studio LFP <studi...@gmail.com> wrote:
>> > I don't think you will be able to do this with a XML layout. You 
>> probably
>> > want to take a look at this
>> >
>> > http://developer.android.com/reference/android/util/DisplayMetrics.ht.
>> ..
>> >
>> > There is both xdpi and ydpi. That should be checked to get the actual 
>> dpi in
>> > both directions and then a view created with those calculations should 
>> get
>> > you where you want to go.
>> >
>> > Here is what I get on a few of my devices in portrait mode:
>> >
>> > // --- Sample Code Start ---
>> > DisplayMetrics metrics = new DisplayMetrics();
>> > Display display = getWindowManager().getDefaultDisplay();
>> > display.getMetrics( metrics );
>> >
>> > Log.i( "TestProject", "X DPI: " + metrics.xdpi );
>> > Log.i( "TestProject", "Y DPI: " + metrics.ydpi );
>> > // --- Sample Code End ---
>> >
>> > *Samsung Galaxy Tab (7 inch):*
>> > X DPI: 168.89351
>> > Y DPI: 169.33333
>> >
>> > *Motorola Droid Bionic:*
>> > X DPI: 258.79245
>> > Y DPI: 256.67368
>> >
>> > *Sony Xperia Play:*
>> > X DPI: 239.05882
>> > Y DPI: 243.72585
>> >
>> > Steven
>> > Studio LFPhttp://www.studio-lfp.com
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-d...@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-develop...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to