I have a layout that has a horizontal container, then 2 vertical containers inside it.
The first vertical container has a web view followed by a textview. The textview does not get created and the webview fills the height. I tried to set the height of the web control by
android:layout_height=”60px”, but it seems like it is not working.
The xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<LinearLayout
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webAuthor"
android:layout_width="60px"
android:layout_height="60px"
android:layout_weight="1.0" />
<TextView
android:id="@+id/textChats"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hello" />
</LinearLayout>
<LinearLayout
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/eventsbakground"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/addbanner"
android:id="@+id/butAdd"
android:layout_gravity="center"
android:layout_marginTop="12px" />
<ListView
android:id="@+id/mylist"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
As mentioned @Vikram Singh , Remove
android:layout_weight="1.0", when you set your view’slayout_weightto “1.0” it means that this view must fill hole parent.With
layout_weightyou can specify a size ratio between multiple views. E.g. you have a MapView and a table which should show some additional information to the map. The map should use 3/4 of the screen and table should use 1/4 of the screen. Then you will set the layout_weight of the map to 3 and the layout_weight of the table to 1. But When you are setting 1 to only one it’ll fill parent