Skip to content Skip to sidebar Skip to footer

How To Add Horizontal Scroll View And A Listview In Android

I am trying to create a application in that i need to create a list view but on the top of that i want a horizontal listview for multiple data .I am confused how can we do this .pl

Solution 1:

What you need is RecyclerView, you can have

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/white"
                    android:clipToPadding="false"/>

Then in code you can set horizontal orientation like this.

mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = newLinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
mRecyclerView.setLayoutManager(mLayoutManager);

And you can use RecyclerView.Adapter for adding views to it. All set :)

Solution 2:

from the picture you've given, I dont think there's a need for a scrollview, you're looking for something like this.

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><com.test.ui.HorizontialListViewandroid:id="@+id/listview"android:layout_width="fill_parent"android:layout_height="wrap_content"/><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="50dp"android:orientation="horizontal">

        // add the layout for filter and sort by here

    </LinearLayout><ListViewandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"></ListView></LinearLayout>

Solution 3:

For horizontal scroll part, use LinearLayout surrounded with HorizontalScrollView and then add each inner LinearLayout programmatically.

And for the below part use custom ListView.

I guess that will do the job.

Solution 4:

May be it will Help You

<HorizontalScrollViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal">

// You can use your own code over here

        <ImageViewandroid:id="@+id/imageView"android:layout_width="100dp"android:layout_height="100dp"android:src="@mipmap/ic_launcher" /><ImageViewandroid:id="@+id/imageView1"android:layout_width="100dp"android:layout_height="100dp"android:src="@mipmap/ic_launcher" /><ImageViewandroid:id="@+id/imageView3"android:layout_width="100dp"android:layout_height="100dp"android:src="@mipmap/ic_launcher" /><ImageViewandroid:id="@+id/imageView4"android:layout_width="100dp"android:layout_height="100dp"android:src="@mipmap/ic_launcher" /><ImageViewandroid:id="@+id/imageView5"android:layout_width="100dp"android:layout_height="100dp"android:src="@mipmap/ic_launcher" /><ImageViewandroid:id="@+id/imageView6"android:layout_width="100dp"android:layout_height="100dp"android:src="@mipmap/ic_launcher" /></LinearLayout></HorizontalScrollView>

Post a Comment for "How To Add Horizontal Scroll View And A Listview In Android"