Ok, so I'm having trouble with this. What I'm trying to do is design a web-based chat interface using 2 webviews (one for the message display and one to send messages). I have the code for everything ready and it works, I just need to figure out the whole layout thing. Here is the code I have:
<?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff" > <WebView android:id="@+id/chatview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="4" /> <WebView android:id="@+id/sendview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </AbsoluteLayout> The program runs in landscape mode. The problems I am running into are: 1) The "chatview" webview is showing up at the bottom instead of the top? 2) When I hit the "back" button the app crashes. I'm guessing this is because the interface isn't designed right, but I could be wrong. Bobbie On Feb 10, 9:52 am, Ludwig <ludwigbrinckm...@gmail.com> wrote: > 2009/2/10 Bobbie <bobbie.st...@gmail.com> > > > > > I have a couple different questions: > > > 1) Does Google think there will only be one screen size on Android > > phones? The reason I ask is because I haven't been able to find > > anything on "variable" layouts in Android? I would like to create a > > layout with 2 webviews, one 80% of screen height and the other 20%. > > Is this even possible, or do I need to assign the height of each as a > > static "px" value? > > Android caters for different screen sizes already. The Openmoko Freerunner > runs Android quite happily on a larger resolution than the G1. If you edit > the skins for your emulator (they are just text files) it is quite easy to > simulate larger (or smaller) screen sizes for development. > > Pretty much all layouts are 'variable', apart from the fixed ones: a > ListView will have more lines on a larger screen etc. > > What you are after is the android:layout_weight="x" attribute for your view > elements. In your case you want, probably inside a LinearLayout, two > elements, one with a weight of 4, the other 1. The weights are relative, so > the first will get 80% of screen height, the other 20. > > HTH > > Ludwig > > > > > 2) How do I preserve the data in my views when someone switches > > between landscape and portrait? I doubt it's hard, but I've not been > > able to find it. Can someone post an example? > > > Thanks everyone! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---