0

I want to know how can I make a 'ListView' to be scrollable horizontally in Xamarin.Android .

Bonucci
  • 51
  • 7
  • Use `RecyclerView` instead, you can make vertical, horizontal and even grid views using it. it also have some more advantages over `ListView`. see [How to build a Horizontal ListView with RecyclerView?](https://stackoverflow.com/questions/28460300/how-to-build-a-horizontal-listview-with-recyclerview) – Mehdi Dehghani Apr 08 '19 at 15:37
  • Possible duplicate of [Horizontal ListView in Android?](https://stackoverflow.com/questions/3240331/horizontal-listview-in-android) – Mehdi Dehghani Apr 11 '19 at 07:54

2 Answers2

1

The best practise is to use RecyclerView as google recommended, and with LinearLayoutManager, items can be shown vertically or horizontally.

For details of implementing a recyclerView, you can refer to RecyclerView

https://learn.microsoft.com/en-us/xamarin/android/user-interface/layouts/recycler-view/

If you insist on using listview to achieved the scrollable horizontally, you can refer to Paul Soucy's HorizontalListView.java and cheesebaron's C# implementation of that

Leon
  • 8,404
  • 2
  • 9
  • 52
0

Here is what I put in the layout file to make it work.

<HorizontalScrollView
    android:layout_weight="50"
    android:layout_width="0dp"
    android:layout_height="150dp" >
    <ListView
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:id="@+id/BarcodeChorusLocalizationListView" />
</HorizontalScrollView>
Bonucci
  • 51
  • 7
  • I help you to up vote, I guess reason of downvote, because you didnot upload your code and what have you achieved now? – Leon Apr 09 '19 at 09:04
  • But this issue, you should use `RecyclerView` to achieve that – Leon Apr 09 '19 at 09:06
  • I am in a hurry to make it and I don't have time to remember how to work with RecyclerViews , so I wanted to know how to make it with ListView. I resolved the problem putting my ListView in a HorizontalScrollView. I put the code in my answer. – Bonucci Apr 09 '19 at 09:16
  • Ok, thanks for your sharing, please mark your reply as answer. Helps other searching for questions to help on so they don't waste time on questions that are answered. – Leon Apr 09 '19 at 09:22