08.04.2011 19:25, Jake Colman пишет:
I have a 2x1 widget with two textviews, aligned top and bottom to the
baseline, that display fine in Portrait.  When I switch to landscape,
there is insufficient room for the two textviews (the widget becomes
long and narrow) so the two textviews overlap each other.

Yep, there is typically less per-widget height in landscape mode.

One way to handle this is to use Launcher shortcut - sized widgets, but those are pretty small. Making larger widgets requires some more work:

What is the correct way to handle this?

Do I need a create a 2x1 landscape layout so that Android will use that
specific layout instead of reusing my one layout?

Yes, make a landscape version with the same name in res/layout-land.

If so, and if that
new layout uses one textview instead of two, how do I know at runtime
which layout is being used?

You don't - especially since onUpdate doesn't get called for widget orientation changes. So whatever you push out into the widget with RemoteViews has to work for both orientations.

Resources do get reloaded though, so you can rely on resource qualifiers like -land, etc.

Or do I keep the code the same and uses the
same IDs on both layouts and updating that second textview id won't hurt
anything?

I'd keep both text views in both layout, using visibility="gone" where a view is not supposed to show - just to be safe.

You could also use one text view, combining data from your original two, in landscape mode. In that case, you'd have a total of three views, and make portrait-only views "gone" in the landscape layout, and vise versa.

-- Kostya

--
Kostya Vasilyev -- http://kmansoft.wordpress.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-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