Android list view inside a scroll view auto scroll issue
Asked Answered
F

1

6

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?

Felton answered 7/3, 2015 at 8:54 Comment(3)
I don't see a question in your paragraph. Could you re-phrase? What is it that you need? Automatic scrolling to a View?Shop
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???Felton
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.Skysweeper
L
32

Add android:descendantFocusability="blocksDescendants" to child of SrollView (and parent of ListView)

Lewan answered 30/10, 2015 at 9:42 Comment(2)
Works like a charm. +1Pulver
It works, but not perfect! It will present the ListView first, then the top item, so it will have a flash...Skelly

© 2022 - 2024 — McMap. All rights reserved.