-1

i am creating an application where requirement is like i have list which scroll vertically and inside that list each item is having one list which must scroll horizontally. So i have to set that list inside horizontal scroll view. i have created a custom adpater for that data is showing on the list everything is working fine but only one problem the list is scrolling vertically because i was unable to set that list horizontal. Please help i have searched lots of answers but it is not working.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="5dp">

        <android.support.v7.widget.CardView
            android:id="@+id/card_view_applicant"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="3dp"
            android:background="#fff"
            app:cardCornerRadius="8dp"
            app:cardElevation="1dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/tv_table_no"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="T1"
                    android:textAlignment="center"
                    android:textColor=" #00008B"
                    android:textSize="25sp"
                    android:textStyle="bold" />

                <View
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="#000000" />

            </LinearLayout>

            <HorizontalScrollView
                android:id="@+id/hsv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fillViewport="true"
                android:measureAllChildren="false"
                android:scrollbars="none">

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_marginLeft="50dp"
                    android:layout_height="match_parent">

                    <ListView
                        android:id="@+id/lv_timing"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"/>

                </RelativeLayout>

            </HorizontalScrollView>

        </android.support.v7.widget.CardView>

    </RelativeLayout>

</LinearLayout>

i have tried to do something like this this is but it is not working,and i don't want to use any recyclerview my requirement is just simple i just want to show some that that's why.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
androider
  • 102
  • 13
  • 1
    https://stackoverflow.com/a/29648713/7666442 – AskNilesh Dec 17 '18 at 06:26
  • @NileshRathod i don't want to use any recyclerview my requirement is just simple i just want to show some that that's why..please help me with this using horizontal scrollview – androider Dec 17 '18 at 06:28
  • Have u checked all answer in that question – AskNilesh Dec 17 '18 at 06:30
  • 2
    `ListView`s will not scroll horizontally. It doesn't matter what container they're in. – Mike M. Dec 17 '18 at 06:31
  • @MikeM. than what should i do? how come it is possible to scroll listview horizontally without recycler view. – androider Dec 17 '18 at 06:32
  • 2
    If you mean that you want the items to scroll in from the sides, rather than the top and bottom, then `ListView` just won't do that. Use a `RecyclerView` instead, as Nilesh suggested. It's really not as complicated as it might seem. – Mike M. Dec 17 '18 at 06:35

2 Answers2

1

You have to use RecyclerView for Horizontal scrollong like:

LinearLayoutManager layoutManager= new 
LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);
zaheer ahmed
  • 168
  • 1
  • 2
  • 11
0

Use android:layout_weight="1" inside ListView. Make LinearLayout the parent layout of ListView instead of RelativeLayout and check it's work or not. I think it should be work.

<LinearLayout
  ..........>
   <ListView
    ........
    android:layout_weight="1"/>
</LinearLayout>
Papan
  • 382
  • 1
  • 10