0

Looking for a horizontal list view GUI componnet in Android similar to UICollectionView in iOS. I trid ListView but was not able to set up to scroll it horizontally.

I need only one line, so no grid like multi line 'table'. I know about TableLayout and GridLayout. Which one is more proper for my purpose?

Looking for not a 3rd party solution but a standard Android one without loading in and library.

János
  • 32,867
  • 38
  • 193
  • 353
  • Possible duplicate of [How to build a Horizontal ListView with RecyclerView?](http://stackoverflow.com/questions/28460300/how-to-build-a-horizontal-listview-with-recyclerview) – Gennadii Saprykin Jun 27 '16 at 18:47
  • The GridView with only one row could help you. TableLayout is not attached to an adapter and didn't recycle views the way recycler View does – Alexandre Martin Jun 27 '16 at 18:56
  • @AlexandreMartin so it is more or less like in iOS, because `UICollectionView` is also a grid-like approach – János Jun 27 '16 at 18:57
  • To be honest, I do not know anything about iOS dev :( – Alexandre Martin Jun 27 '16 at 18:59
  • use the RecyclerView as shown on the question linked by Gennadi – Budius Jun 27 '16 at 19:10
  • @AlexandreMartin I tried `GridView` but can not set column number, or if I set it to a heigher number, then cell content will be reduced. Seems horizontal scroll not possible with `GridView`. – János Jun 28 '16 at 12:13

2 Answers2

0

You should be using the RecyclerLayout, which allows you to specify your own LayoutManager (then you can specify a horizontal one, or a vertical one, or a grid one, or...)

Here is a good SO with a simple example: How to build a Horizontal ListView with RecyclerView?

Community
  • 1
  • 1
Booger
  • 18,579
  • 7
  • 55
  • 72
0

You can use RecycleView and add horizontal layoutmanager

RecyclerView listView= (RecyclerView)findViewById(R.id.hlistview);

        LinearLayoutManager layoutManager=new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
        listView.setLayoutManager(layoutManager);

and in xml

<android.support.v7.widget.RecyclerView
        android:id="@+id/hlistview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="30dp"/>
Vikash Kumar Verma
  • 1,068
  • 2
  • 14
  • 30