I want to achieve Fig-1 but I am stuck with Fig-2 and not able to see full gridview as a header of Listview.
As you can see the gridview is not showing fully and hiding behind Listview in Fig-2
Gridview xml :
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview"
android:numColumns="2"
android:stretchMode="columnWidth"
android:cacheColorHint="#ffffffff"
android:gravity="center"
android:verticalSpacing="5dp"
android:horizontalSpacing="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
Listview xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<ListView
android:id="@+id/listview"
android:scrollbars="vertical"
android:background="#fff"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</RelativeLayout>
Fragment code :
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view=inflater.inflate(R.layout.fragmentpage_layout, null);
listView=(ListView)view.findViewById(R.id.listview);
header=inflater.inflate(R.layout.gridview_layout,null);
gridView=(GridView)header.findViewById(R.id.gridview);
listView.addHeaderView(header);
gridViewAdapter=new CustomGridViewAdapter(getActivity(),images,toptexts, bottomtexts);
listViewAdapter=new CustomListViewAdapter(getActivity(),images,toptexts,bottomtexts);
gridView.setAdapter(gridViewAdapter);
listView.setAdapter(listViewAdapter);
return view;
}
Thanks In Advance.