Hi James, thanks for sharing your discoveries about this.

Indeed, that was an strange decision from the Android team to provide 
ranges. I wonder why the launcher couldn't report *actual* width and height 
occupied by a widget.

By the way, I was going to answer your question before with this SO link 
(perhaps it helps a bit 
more): 
http://stackoverflow.com/questions/17138191/android-widget-resizing/19670267#19670267



El martes, 30 de diciembre de 2014 23:14:11 UTC-3, Dusk Jockeys Android 
Apps escribió:
>
> Ok, answering my own question. :)
>
> The anomaly is due to landscape. A 2x2 widget that looks approximately 
> square on a portrait screen looks shorter and much wider in landscape mode, 
> as it has to fit a shorter and wider screen orientation. 
>
> So in the landscape situation:
>
> The actual widget WIDTH in pixels corresponds exactly 
> to OPTION_APPWIDGET_MAX_WIDTH * screen density.
> The actual widget HEIGHT in pixels corresponds exactly to 
> OPTION_APPWIDGET_MIN_HEIGHT * screen density.
>
> So the ranges seem to be covering the maximum and minimum dimensions 
> possible for both orientations. Would be nice if the docs could make that 
> clear. 
>
>
>
> On Tuesday, December 30, 2014 12:23:34 PM UTC+8, Dusk Jockeys Android Apps 
> wrote:
>
>> Sorry just to clarify a typo:
>>
>> The actual widget WIDTH in pixels corresponds exactly 
>> to OPTION_APPWIDGET_MIN_WIDTH * screen density.
>> The actual widget HEIGHT in pixels corresponds exactly to 
>> OPTION_APPWIDGET_MAX_HEIGHT * screen density.
>>
>> I really don't understand why the actual width would match the _MIN_WIDTH 
>> value, but the actual height would match the _MAX_HEIGHT value. That 
>> doesn't make any sense to me.
>>
>> The (OPTION_APPWIDGET_MIN_HEIGHT* screen density) value doesn't seem to 
>> relate to anything, it is far too small for the actual widget height, and 
>> the (OPTION_APPWIDGET_MAX_WIDTH* screen density) value  is ridiculous, 
>> wider than the actual screen resolution. 
>>
>>
>>
>>
>> On Tuesday, December 30, 2014 12:28:27 AM UTC+8, Dusk Jockeys Android 
>> Apps wrote:
>>
>>> The docs refer to the following:
>>>
>>> onAppWidgetOptionsChanged() 
>>>
>>> This is called when the widget is first placed and any time the widget 
>>> is resized. You can use this callback to show or hide content based on the 
>>> widget's size ranges. You get the size ranges by calling 
>>> getAppWidgetOptions(), which returns a Bundle that includes the following:
>>> •OPTION_APPWIDGET_MIN_WIDTH—Contains the lower bound on the current 
>>> width, in dp units, of a widget instance.
>>> •OPTION_APPWIDGET_MIN_HEIGHT—Contains the lower bound on the current 
>>> height, in dp units, of a widget instance.
>>> •OPTION_APPWIDGET_MAX_WIDTH—Contains the upper bound on the current 
>>> width, in dp units, of a widget instance.
>>> •OPTION_APPWIDGET_MAX_HEIGHT—Contains the upper bound on the current 
>>> width, in dp units, of a widget instance.
>>>
>>> Can anyone explain what these ranges actually mean, and why there is a 
>>> range at all, as opposed to the actual resized values. 
>>>
>>> Because if I look at the values after a resize and compare it to the 
>>> screen area covered by the widget, the results seem very strange.
>>>
>>> The actual widget width in pixels corresponds 
>>> to OPTION_APPWIDGET_MIN_WIDTH * screen density.
>>> The actual widget width in pixels corresponds to 
>>> OPTION_APPWIDGET_MAX_HEIGHT * screen density.
>>>
>>> Yep, you read that right, the MIN width, but the MAX height!?
>>>
>>> I want to work out the general size and aspect ratio of the resized 
>>> widget so I can adjust the layout, as recommended by the docs, but just 
>>> getting the widget size seems unnecessarily opaque. 
>>>
>>> Does anyone know?
>>>
>>> Thanks
>>> James
>>>
>>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to