Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ScrollViews layout into HorizontalScrollView

I want to create a sort of card layout with cards that contain a ListView layout inside a HorizontalScrollableView that can scroll the cards horizontally. Everything is working but I have problem with scrolling. I can scroll the listview vertically only if I am not scrolling the cards horizontally and viceversa.

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 the listview items to the linear layout. I would like to allow vertical and horizontal scrolling smoothly without these kind of limitations (simultaneous horizontal and vertical scrolling).

How can I achieve this?

like image 695
Matroska Avatar asked Jun 27 '12 20:06

Matroska


2 Answers

Check out this, might help you implement custom two-way scrolling layout.

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

If you want any of ListView features though (like view recycling, filtering, adapters) - things are going to get more complicated.

like image 99
Ivan Bartsov Avatar answered Nov 15 '22 06:11

Ivan Bartsov


I would suggest you to take ViewFlipper to give scroll effect horizontally. Then add ListView to flipper as a child. Use gesture to move it right and left.

ListView will still scroll vertically and if you are not able to set OnItemClickListener to ListView then you can use SingleTap method of Gesture.

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

like image 23
Tofeeq Ahmad Avatar answered Nov 15 '22 05:11

Tofeeq Ahmad