I want design layout same like my attached image, this listview can horizontal and vertical scroll. I create header A B C by gridview, but not add list view in the rest.
Image:
I want design layout same like my attached image, this listview can horizontal and vertical scroll. I create header A B C by gridview, but not add list view in the rest.
Image:
As I understand, you try to put above a ListView
, a ScrollView
or a GridView
another GridView
as an HeaderView
which this scrolls horizontally. It seems like adding several widgets which have their own handling of scroll event.. Don't know if this is possible.
Try another way, change your GridView
as a HorizontalScrollView
and put your views A, B, C.. inside.
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
Here, your views A, B, C...
</HorizontalScrollView>
See an example of this simple layout: Scrollabale listview in both direction with header using Horizontal scrollview.
Then if you want to scroll the content but keep the header part fixed, try to add this layout above your content with a ViewGroup
container (inside LinearLayout, RelativeLayout or something else) with an include:
<RelativeLayout
... >
<include
android:layout="@layout/layout_horizontal_scrollview"
... >
<ListView
... >
</RelativeLayout>
This should do the trick..
But if you want that your header part scroll at the sime time to your content, try to add this layout as a HeaderView
(I've just try this, it works):
Create an HorizontalScrollView
for header:
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
Here, your views A, B, C...
</HorizontalScrollView>
Inflate this layout as a HeaderView
:
View header = View.inflate(this, R.layout.layout_horizontal_scrollview, null);
listview.addHeaderView(header);
Note: add a HeaderView
to a GridView isn't possible, you could do this with a special adapter (like HFGridView).
Compose them (GridView
and ListView
) in RelativeLayout
or vertical oriented LinearLayout
this way:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/gridview" >
</RelativeLayout>
Item to ListView is added programmatically by setting data to adapter.
Edit (enabling vertical and horizontal scroll): Try this How can I make my layout scroll both horizontally and vertically?.