Bonucci
Bonucci

Reputation: 51

How to make a ListView scrollable horizontally(Xamarin.Android)?

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

Upvotes: 0

Views: 369

Answers (2)

Bonucci
Bonucci

Reputation: 51

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>

Upvotes: 0

Leon Lu
Leon Lu

Reputation: 9264

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

Upvotes: 1

Related Questions