0

I created horizontal scrollable listview. And I can populated from db without any problem. The problem is; the entire length of the items are setted to the length of the first item.

Like this

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
  <HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
            <ListView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
   </HorizontalScrollView>
</RelativeLayout>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • Never add a RecyclerView or ListView to a scroll view. Doing so results in poor user interface performance and a poor user experience.https://developer.android.com/reference/android/widget/ScrollView.html. You could use a ReyclerView for this purpose – Raghunandan Sep 12 '17 at 08:49

2 Answers2

3

Simple solution to this problem is to use Recyclerview instead of List View. Adding HorizontalScrollview to LinearLayout will not work. I have already tried many solutions posted here after a lot of search I come to this point my solution was Recyclerview. And from here i learned,How to use this.

Khubaib Raza
  • 543
  • 6
  • 10
Suleman
  • 387
  • 5
  • 12
0

You need to make listView height match the parent

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
   <HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
   </HorizontalScrollView>
</RelativeLayout>
Shriyansh Gautam
  • 1,084
  • 1
  • 7
  • 13