Search code examples
androidandroid-edittextandroid-scrollview

How to scroll ScrollView of EditTexts?


I have following layout:

<ScrollView>
    <LinearLayout>
        <EditText/>
        <EditText/>
        ...
        <EditText/>
    </LinearLayout>
</ScrollView>

EditTexts are added dynamically to the ScrollView.

EditTexts should be focusable(at least focusableInTouchMode)

The question is - how to scroll that view with touching on one of the EditTexts and making a scroll gesture), since now scrolling the works only if touching outside of the EditTexts? Is it possible at all?

UPD Marked the first answer as a solution(with plain solution to provide a scroll), since my question is incorrect and answer is plain right - my scrolling problem was a result of using a ScrollView inside another ScrollView.

Sorry for misdirection.


Solution

  • A ScrollView can only have one child, so you should make a LinearLayout in the ScrollView and then add the EditTexts to it. The scrolling should then work automatically when necessary.