Reputation: 54949
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 ?
Upvotes: 0
Views: 5089
Reputation: 3433
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);
}
}
Upvotes: 1
Reputation: 10349
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
Upvotes: 1
Reputation: 7018
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);
}
Upvotes: 2
Reputation: 16191
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.
Upvotes: 1
Reputation: 5900
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);
Upvotes: 4