[ below ]
09.04.2011 0:12, Jake Colman пишет:
>>>>> "KV" == Kostya Vasilyev<[email protected]> writes:
KV> 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.
[snip]
KV> I'd keep both text views in both layout, using visibility="gone"
KV> where a view is not supposed to show - just to be safe.
KV> You could also use one text view, combining data from your
KV> original two, in landscape mode. In that case, you'd have a total
KV> of three views, and make portrait-only views "gone" in the
KV> landscape layout, and vise versa.
But if onUpdate is not called on changes to orientation, how do you know
a) which layout to reference and b) which visibility to make "gone"?
Jake,
That's my point exactly - you don't know, and shouldn't care, because
you switch layouts in the .xml, not from code.
The RemoteViews in your code needs to cover both orientations. You do
this by using the same layout name (resource id) for both portrait and
landscape orientations, let's say one in res/layout, and the other in
res/layout-land.
Now you have two .xml layout files, which, because of having the same
name, are two versions of the same layout. Same as for regular
(non-widget) layouts, really. Put text views with the same IDs into
those .xml files, and mark them as visible and gone as needed.
Your RemoteViews will have a layout resource ID that common to both
portrait and landscape .xml's, but which of those two layouts is loaded
will depend on home screen orientation - just like with regular Activity
type layouts.
If home screen orientation is changed, the home screen app will go
through the usual activity orientation change cycle, and, based on the
same resource ID, will load the layout appropriate for the new
orientation. Same as for non-widget activities in any application.
As for putting data into text views - your code should always specify
values for all text views used in both orientations, because a view
that's "gone" now can become "visible" after a home screen orientation
change.
-- Kostya
-- Jake Colman -- Android Tinkerer
-- 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
--
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 [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