-1

enter image description here

How to create a HorizantalScrollview for this, but when I keep button in HorizantalScrollview button width changes to wrap_contantI want it to be match_parent only and when I swipe the button I need to get the RecyclerView for RecyclerView I can manage by keeping the LinearLayout.Horizantal in code. All want is button to be Match_Parent and when I swipe I need to get recyclerview

Gowthaman M
  • 8,057
  • 8
  • 35
  • 54
Maharsh
  • 53
  • 5
  • Why use `HorizantalScrollview` just use `RecyclerView` only . You can inflate different layouts depending on position . – ADM Sep 13 '18 at 05:49
  • Look at this examples https://android-pratap.blogspot.com/2015/12/horizontal-recyclerview-in-vertical.html – Gowthaman M Sep 13 '18 at 06:00

2 Answers2

0

While the setup you've shown in the illustration should be doable, it is not considered a good practice. RecyclerView brings efficiency to a scrollable element and putting RecyclerView in another scrollable element (e.g. the HorizontalScrollView in your example) can make the efficiency benefits go away and can make it less UX-friendly.

What you should do is to create a RecyclerView that can handle multiple view types in the Adapter. This SO answer should be enough for you to understand the concept.

And your case should look more like this:

recycler

(the illustration is for explaining purposes only, it's not entirely accurate as the RecyclerView should not wrap its content)

Bartek Lipinski
  • 30,698
  • 10
  • 94
  • 132
0

Use HorizontalScrollView it's very simple like normal scrollview

See below example

 <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scrollbarThumbHorizontal="@null" \\remove it if you don't want to use
            android:scrollbarThumbVertical="@null" \\optional
            android:scrollbarTrackHorizontal="@null" \\optional
            android:layout_marginLeft="@dimen/margin_15dp"
            android:scrollbars="horizontal">

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

\\define your list of item here that you want to scroll


 </LinearLayout>
        </HorizontalScrollView>
Praveen Kumar
  • 277
  • 2
  • 12