Android how to display 2 listviews in one activity one after the other

activity_main.xml <ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:fillViewport=”true” > <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” android:padding=”10dip” > <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:gravity=”center_vertical” android:text=”ANDROID” /> <ListView android:id=”@+id/listView1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginTop=”10dip” android:background=”#B29090″ > </ListView> <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginTop=”10dip” android:gravity=”center_vertical” android:text=”IOS” /> <ListView android:id=”@+id/listView2″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginTop=”10dip” android:background=”#4A9C67″ > </ListView> </LinearLayout> </ScrollView> MainActivity.java package com.example.listviewin1xmldemo; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.view.View.MeasureSpec; … Read more

Linear Layout and weight in Android

3 things to remember: set the android:layout_width of the children to “0dp” set the android:weightSum of the parent (edit: as Jason Moore noticed, this attribute is optional, because by default it is set to the children’s layout_weight sum) set the android:layout_weight of each child proportionally (e.g. weightSum=”5″, three children: layout_weight=”1″, layout_weight=”3″, layout_weight=”1″) Example: <LinearLayout android:layout_width=”fill_parent” … Read more