Scroll to a specific view in scroll view

前端 未结 15 1404
醉梦人生
醉梦人生 2020-12-04 14:08

I have added a scrollview and the subchilds inside the scrollview. At some point i need to scroll to a specific view.



1. 

        
相关标签:
15条回答
  • 2020-12-04 14:53

    Try to call view.requestFocus() on the view you want to scroll to.

    0 讨论(0)
  • 2020-12-04 14:55

    For Kotlin user. If above code are not worked. Try it.

    val your_scrollview = findView...
    val your_view_inside_SV = findView...
    your_scrollview.post( { your_scrollview.scrollTo(0, your_view_inside_SV.getY().toInt()) })
    
    0 讨论(0)
  • 2020-12-04 14:56

    You can use method smoothScrollTo to scroll to specific view in scroll view. - Example:

    my_scroll_View.smoothScrollTo(0, editText.getBottom());
    

    Good luck!

    0 讨论(0)
提交回复
热议问题