>>>>> "KV" == Kostya Vasilyev <[email protected]> writes:
KV> [ below ] KV> 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"? >> KV> Jake, KV> That's my point exactly - you don't know, and shouldn't care, KV> because you switch layouts in the .xml, not from code. KV> The RemoteViews in your code needs to cover both KV> orientations. You do this by using the same layout name (resource KV> id) for both portrait and landscape orientations, let's say one KV> in res/layout, and the other in res/layout-land. KV> Now you have two .xml layout files, which, because of having the KV> same name, are two versions of the same layout. Same as for KV> regular (non-widget) layouts, really. Put text views with the KV> same IDs into those .xml files, and mark them as visible and gone KV> as needed. KV> Your RemoteViews will have a layout resource ID that common to KV> both portrait and landscape .xml's, but which of those two KV> layouts is loaded will depend on home screen orientation - just KV> like with regular Activity type layouts. KV> If home screen orientation is changed, the home screen app will KV> go through the usual activity orientation change cycle, and, KV> based on the same resource ID, will load the layout appropriate KV> for the new orientation. Same as for non-widget activities in any KV> application. KV> As for putting data into text views - your code should always KV> specify values for all text views used in both orientations, KV> because a view that's "gone" now can become "visible" after a KV> home screen orientation change. KV> -- Kostya Kostya, This worked perfectly. Thanks! ...Jake -- 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

