0

Of course a ListView in a ScrollView is problematic since the ScrollView wouldn't receive scroll gestures which are performed inside the ListView . So I thought about a solution like this: The ListView itself should have the height of the sum of the heights of all its elements such that scrolling inside the ListView is impossible. Thus, scroll gestures are always passed to the ScrollView. Is this somehow possible (I'd like to see some XML code)?

Note: I want to have more Views in the ScrollView than just my ListView. Otherwise I could just omit the ScrollView and directly take a ListView.

Example of the content of my ScrollView:

    TextView
    Item 1 of my ListView
    Item 2 of my ListView
    Item 3 of my ListView
    Item 4 of my ListView
    Item 5 of my ListView
    ...
    Item n of my ListView
    EditText
    TextView
    TextView
    Button

Since the number of items in the ListView might be very high I have to use a ScrollView in order to let the user see all Views. Omitting the ListView and just hardcoding the Items of the ListView into the ScrollView is not possible because the number of items in the list is supposed to be dynamic.

principal-ideal-domain
  • 3,998
  • 8
  • 36
  • 73

1 Answers1

0

Get rid of the ScrollView, and add a Header to your ListView that contains one TextView and a Footer that is a FrameLayout (or similar) containing the EditText, the TextViews (both) and the Button. For more information about how to do that, see this SO question/answer.

Or use the getItemType() method as described in this SO answer.

Community
  • 1
  • 1
Martin Marconcini
  • 26,875
  • 19
  • 106
  • 144