简体   繁体   中英

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>

If you want to create horizontal list you can use:

1) RecyclerView with GridLayoutManager.HORIZONTAL or LinearLayoutManager.HORIZONTAL

2) HorizontalVariableListView

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM