Using ScrollViews Layout in HorizontalScrollView

I want to create a map view with maps that contain a ListView layout inside a HorizontalScrollableView that can scroll the maps horizontally. Everything works, but I have problems with scrolling. I can scroll the list vertically only if I do not scroll the cards horizontally and vice versa.

This is the main container:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <HorizontalScrollView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ddd" > <LinearLayout android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > </LinearLayout> </HorizontalScrollView> </RelativeLayout> 

I inflate and add list items to the linear layout. I would like for smooth vertical and horizontal scrolling without these restrictions (simultaneous horizontal and vertical scrolling).

How can i achieve this?

+6
source share
3 answers

Check this out, it can help implement a custom two-sided scrollable layout.

https://github.com/ened/Android-Tiling-ScrollView/blob/master/src/asia/ivity/android/tiledscrollview/TwoDScrollView.java

If you want any ListView functions (for example, image processing, filtering, adapters), everything will become more complicated.

+2
source

I suggest you use ViewFlipper to provide a horizontal scroll effect. Then add ListView to flipper as a child. Use the gesture to move it left and right.

The ListView will still scroll vertically, and if you cannot set OnItemClickListener to the ListView, you can use the SingleTap Gesture method.

ListView inside View discussion flipper 1 and ListView inside View Flipper Discuss 2

+1
source

I would suggest that your horiziontallayout be the root view that you return to getView () in your adapter. Thus, each line will scroll separately from each other. If this does not work right away, you may need to setItemsCanFocus (true) for your rows to provide input to your horizontalscrollview.

0
source

Source: https://habr.com/ru/post/919182/


All Articles