This is My Example in which I am using Image view and List view in Scroll view
You can add your own two Tabs in XML there will be no difference
Hope so this will helps.
Layout.xml
<ScrollView
android:id="@+id/sv_itemRank"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/img_item_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/empty"
android:scaleType="centerCrop" />
<ListView
android:id="@+id/lv_items_lists"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:divider="@null"
android:dividerHeight="0dp"
android:scrollbars="none" >
</ListView>
</LinearLayout>
</ScrollView>
and after populating the listview in my case I am using custom adapter call this function to set Height of List View Based on Children
I done this after adapter.notifyDataSetChanged();
you change it respective to your code.
Code for setListViewHeightBasedOnChildren(listview)
pass your listview as parameter.
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(),
MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth,
LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}