<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.85"
android:orientation="horizontal" android:layout_marginTop="10px">
<EditText
android:id="@+id/editText1"
android:layout_width="299dp"
android:layout_height="wrap_content"
android:layout_weight="1" android:lines="1"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="clear" />
</LinearLayout>
<ListView
android:id="@+id/mylist"
android:layout_height="413dp"
android:layout_weight="0.52" android:layout_width="fill_parent">
</ListView>
</LinearLayout>
What’s wrong with that layout?
1) when I open the app in portrait mode this TextEdit is visible until I click it in order to enter some text (there is only blackness). If I than turn it into landscape mode the textedit appears again (in full screen mode)
2) when I open the app in landscape mode there is only layout header and the blackness below again.
It doesn’t seem too complex..
Here is the pseudo-xml:
<row>
<col. for text>
<col. for button>
</row>
<row>
<some text here>
</row>
Can you help me fix this layout or give me some better example?
You have a listview with a height of 413dp (pretty huge). I think you misunderstand that layout_weight determines how to assign excess space, of which there’s not going to be very much given your listview is so big.
What you probably want is to set your horizontal linearlayout to have no layout_weight and tell the listview to use it all: