I have an android layout setup where I have a ScrollView with some elements and inside that I have a ListView. I am using StackOverflow's answer Android list view inside a scroll view for achieving this feature and it's working fine. My ListView is below some elements like TextView, ImageView. Problem is that when the page is presented ListView get scrolled automatically so that first item in listView is at the top (ie whole scrollview gets scrolled to present listview first item). How can I avoid this auto scrolling?
Asked
Active
Viewed 2,516 times
6
-
I don't see a question in your paragraph. Could you re-phrase? What is it that you need? Automatic scrolling to a `View`? – George Daramouskas Mar 07 '15 at 09:07
-
Page shouldn't get scrolled without user interaction. But in my case when the view is presented whole page gets scrolled so that list view is at the top of page. ListView is showing prior to the details that is displayed above the listview.So the user is compelled to scroll down to view the details that is displayed above the listview.Any solution??? – althaf_tvm Mar 07 '15 at 09:19
-
If I understand correctly, your ListView is shown first before your TextView even though it's layout is on top vertically, and that is not desired. Would it work if you call scrollTo method of ScrollView. FYI, I never had to use ScrollView. – The Original Android Mar 07 '15 at 18:26
1 Answers
32
Add android:descendantFocusability="blocksDescendants"
to child of SrollView (and parent of ListView)

Alex
- 716
- 8
- 9
-
-
-
It works, but not perfect! It will present the ListView first, then the top item, so it will have a flash... – bony Aug 11 '16 at 13:46