How would I detect the orientation to set the layout? I am trying Timo's tip on the 0px, layout_weight=1
On Feb 13, 12:30 pm, loty <lev.pert...@gmail.com> wrote: > I would also suggest using different layout files for different screen > sizes andorientation. It works very well and much easier to control > than any 'smart' resizing code. Look into API docs for explanation of > resource folder naming conventions. > > On Feb 12, 7:26 pm, Timo Bruck <timot...@gmail.com> wrote: > > > Android will automatically re-layout your views based onorientation(and > > screen size, too!), but you need to give it flexibility in setting the view > > sizes to do that. > > > I try to avoid using absolute dimensions for anything other than padding or > > when I want a view to be a certain size regardless of screen size (e.g. the > > height of a button). > > > I think what you want to do is set the layout_height of your EditText and > > WebViews to 0px, and then add a layout_weight="1" to each of them. This will > > tell Android to divide up any extra screen space between those two views > > equally. > > > Alternatively, you could also have two different layout files (one for > > landscape and one for portrait). > > > -Timo > > > On Thu, Feb 12, 2009 at 3:54 PM, David <godsinven...@gmail.com> wrote: > > > > Hello, I need to have my viewresizeitself based on theorientation. > > > After extensive googling (maybe i was using the wrong terms) I could > > > find nothing telling me how to detect when theorientationwas > > > changed. Here is my layout file: > > > > <?xml version="1.0" encoding="utf-8"?> > > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > > > android" > > > android:orientation="vertical" > > > android:layout_width="fill_parent" > > > android:layout_height="fill_parent" > > > > <EditText android:id="@+id/htmledit" > > > android:layout_width="fill_parent" > > > android:layout_height="200px" > > > /> > > > <WebView android:id="@+id/htmlview" > > > android:layout_width="fill_parent" > > > android:layout_height="200px" > > > /> > > > </LinearLayout> > > > > how do I have it automaticallyresizeitself? I want each item (the > > > EditText and the WebView) to fill half the screen (not counting the > > > title/notification bars). I set the height to absolute and not > > > wrap_content because wrap_content defaults to 1 line for EditText and > > > nothing for WebView. and fill_parent has the EditText on top of the > > > WebView. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---