Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android list view inside a scroll view auto scroll issue

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?

like image 411
althaf_tvm Avatar asked Mar 07 '15 08:03

althaf_tvm


People also ask

How do I stop list view from scrolling?

Just call stopScroll(myListView); when you need to stop scroll. Show activity on this post. // Stop scrolling smoothScrollBy(0, 0);

How do I make ListView scroll smoothly?

The key to a smoothly scrolling ListView is to keep the application's main thread (the UI thread) free from heavy processing. Ensure you do any disk access, network access, or SQL access in a separate thread. To test the status of your app, you can enable StrictMode .

Does ListView scroll android?

Never put ListView in ScrollView . ListView itself is scrollable.

What is nested scroll view?

NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.


1 Answers

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

like image 56
Alex Avatar answered Oct 21 '22 06:10

Alex