Lion789
Lion789

Reputation: 4482

How to create a horizontal list view? Android

I am having a hard time creating a horizontal listview, I want all the items to be scrollable horizontally. I tried this but the list still appears in its regular format.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TEST TO SEE IF HORIZ"/>
<HorizontalScrollView
    android:layout_width="wrap_content"
    android:layout_height="fill_parent">



        <ListView
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:id="@+id/listViewGlobal"
            android:ori>

            </ListView>


    </HorizontalScrollView>
</RelativeLayout>

Upvotes: 1

Views: 2364

Answers (2)

mmlooloo
mmlooloo

Reputation: 18977

If you want to create horizontal list you can use:

1)RecyclerView with GridLayoutManager.HORIZONTAL or LinearLayoutManager.HORIZONTAL

2) HorizontalVariableListView

Upvotes: 1

antonio
antonio

Reputation: 18242

Your problem is that you are putting a ListView inside an HorizontalScrollView and the vertical scroll that you are experiencing is caused by the ListView.

Change your ListView for a LinearLayout inside you HorizontalScrollView to make it work.

Also, take a look at Horizontal ListView in Android?

Upvotes: 0

Related Questions