0

I have to implement the screen below. It looks perfectly fine on a 480*800 pixel screen. On a low resolution screen because of the lack of screen size the Scrolling of the Results exposes very small real estate for the user to scroll thru the results.

Which is the best way to implement it ?

enter image description here

Harsha M V
  • 54,075
  • 125
  • 354
  • 529
  • 3
    **DON'T** put `Listview` inside a `Scrollview`. It'll apparently spell disaster.. See [this](http://groups.google.com/group/android-beginners/browse_thread/thread/2d1a4b8063b2d8f7) – Ghost Mar 21 '12 at 12:14
  • In this link, I write my solution to put a scrollable listview inside of a scrollview. I think that it can help you, if I understood your question [https://stackoverflow.com/questions/15968766/listview-inside-scroll-view-magic/21560592#21560592](https://stackoverflow.com/questions/15968766/listview-inside-scroll-view-magic/21560592#21560592) – Alan Donizete Feb 04 '14 at 18:45

5 Answers5

4

I always find trying to put something that scrolls into something else that scrolls is a nightmare so I would probably put the top of your view (results Bangalore to Mysore Date) inside the ListView header,that way it will scroll off the screen

listView.addHeaderView(listViewHeader);
triggs
  • 5,890
  • 3
  • 32
  • 31
2

They are right. You shouldn't place listview into scrollview. Instead of it try this:

 <ScrollView android:layout_width="fill_parent" android:scrollbars="vertical"  
android:layout_height="wrap_content" android:scrollbarStyle="insideOverlay">  
<LinearLayout 
android:id="@+id/itemContainer"
android:orientation="vertical" 
android:layout_width="fill_parent"
android:layout_height="wrap_content"  
>     
<!-- YOUR ELEMENTS WILL BE PLACED HERE -->
 </LinearLayout>
</ScrollView>

Then you can add items from code:

private LinearLayout container; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState);                
    setContentView(R.layout.YOUR_XML);  
    container = (LinearLayout)findViewById(R.id.itemContainer);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( 
             LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 
/*CREATE YOUR ITEM*/
/*AND PLACE IT INTO CONTAINER*/
container.addView(YOUR_ITEM, layoutParams);
} 
Nolesh
  • 6,848
  • 12
  • 75
  • 112
1

You can put a ListView inside a ScrollView. Just extend the ListView to override the onTouchEvent method. Like so

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class ChildScrollView extends android.widget.ListView {
    private int parent_id;

    public ChildListView(Context context) {
        super(context);
    }

    public ChildListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ChildListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event){
        requestDisallowInterceptTouchEvent(true);
        return super.onTouchEvent(event);
    }
}
JackMahoney
  • 3,423
  • 7
  • 32
  • 50
1

Put the portion you've shown in red border in a ListView which has Custom List Items. You don't really need a scrollview I guess. Just set the sort and filter buttons to parent bottom. And The listview between the buttons and the part above the list items. Best of luck.

Rajkiran
  • 15,845
  • 24
  • 74
  • 114
1

I tried using ListView inside ScrollView by using my own code available as answer at below link. Its working fine for me. Check it once and try it if you feel its good.

How to use listview inside scroll view

Community
  • 1
  • 1
Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67