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?

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? Commented Mar 7, 2015 at 9: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??? Commented Mar 7, 2015 at 9: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. Commented Mar 7, 2015 at 18:26

1 Answer 1

32

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

Sign up to request clarification or add additional context in comments.

2 Comments

Works like a charm. +1
It works, but not perfect! It will present the ListView first, then the top item, so it will have a flash...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.