Using -port and -land qualifiers, with same image name, is the right thing
to do. This leverages the usual resource loading mechanism when those images
are accessed by the launcher.

Managing images per orientation from code is a path leading only to pain and
madness, as that requires tracking the home screen's orientation (which, in
the general sense, may not be the same as the device's, and often is not).

Jona,

Make sure that every single RemoteViews object you push to the widget has
all the images (and text and pending intents) that bring it up to date. Do
not push one update for a button, another for a line of text, and then yet
another for a pending intent. All but the most recent one will be lost after
an orientation change.

-- Kostya
2011/6/17 ThaMe90 <[email protected]>

> You might have different images for different screen orientations, but
> the names of the images are the same:
>
> button_image_on.png
> button_image_off.png
>
> Because the names are the same the OS doesn't know which you want it
> to show. Putting the images in different subfolders doesn't matter, as
> the Resource file that is created for you doesn't consider those, only
> the names of the items in the folders (which are set as the id). The
> only way you get what you want is to change the names of the images...
>
> Maybe you could use:
>
> button_port_on.png
> button_port_off.png
> button_land_on.png
> button_land_off.png
>
> On 17 jun, 16:48, Jona <[email protected]> wrote:
> > I think there is a bug somehow on the Android OS. I'm using HTC EVO which
> on
> > the home screen it never goes to landscape as it was intended by HTC.
> >
> > *Here is my setup:*
> >
> > drawable-port/button_image_on.png
> > drawable-port/button_image_off.png
> > drawable-land/button_image_on.png
> > drawable-land/button_image_off.png
> >
> > On my home screen widget I toggle the images depending on the received
> > broadcast intent.
> >
> > This is what I use to change the image from within the AppWidgetProvider:
> >
> > if (toggleOn)
> > {
> >    views.setImageViewResource(R.id.button_image_on,
> R.drawable.button_image_on);}
> >
> > else
> > {
> >    views.setImageViewResource(R.id.button_image_on,
> R.drawable.button_image_off);
> >
> > }
> >
> > The problem I'm having is that some cases the land images are shown when
> the
> > phone is in port mode.
> >
> > To reproduce easily from my application I send a broadcast intent to
> toggle
> > image state on the widget. I send this intent while the app is in
> landscape
> > mode. Than when I got to the homescreen bam! the widget in port mode is
> > using a land image! Odd right?
> >
> > Anyone run into a similar issue?
>
> --
> 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 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