That was written before there was multiple densities, so you should take 74
as in dp.  So that is 74 pixels in mdpi, 1.5x in hdpi, etc.

An mdpi device with a 480x800 screen has more layout space than a 480x800
hdpi screen.  So the size of the widgets in pixels is still 74, but launcher
can just put more widgets on its screen because it has more space.  It would
definitely be covered by more than 3 cells.

On Mon, Jan 17, 2011 at 8:54 AM, Cleverson <[email protected]> wrote:

> Hi,
>
> I'm trying to understand how the home screen calculates how many cells
> will be assigned to a given widget. I came across the following
> sentence in the Android Developer Site:
>
> "Because the Home screen's layout orientation (and thus, the cell
> sizes) can change, as a rule of thumb, you should assume the worst-
> case cell size of 74 pixels for the height and width of a cell.
> However, you must subtract 2 from the final dimension to account for
> any integer rounding errors that occur in the pixel count. To find
> your minimum width and height in density-independent pixels (dp), use
> this formula:
> (number of cells * 74) - 2
> Following this formula, you should use 72 dp for a height of one cell,
> 294 dp and for a width of four cells."
>
> What if I have a mdpi (160dpi) device whose resolution is 480x800?
>
> In a mdpi device, each 1 dip stands for 1 pixel. So, if my widget is
> 72dip x 294dip, it would take 72px x 294px in the mdpi device.
> As far as I cound understand, in the example above, the widget would
> not take 4 cells in this device. The device is 480 pixels wide and 294
> pixels would be covered by 3 cells.
>
> Who's wrong here? The formula or my interpretation?
>
> Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

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.

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

Reply via email to