简体   繁体   中英

How to prevent scrollview from scrolling on adding new view to the content layout

I have a LinearLayout inside a scrollview, When i add new content to the LinearLayout scrollview scrolls to that content and then jumps back to top. How do i prevent this ie I want the scrollview to stay at the current position irrespective of addition or removal of new content. I've tried

  1. Setting descendantFocusability to blocksDescendants
  2. Diable scrollview before adding new views

You can get the OnSizeChanged events of the LinearLayout by making your own LinearLayout and overriding protected void onSizeChanged . Determine the difference in oldh and h, and then scrollview.setScrollY to compensate for the difference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM