android how to scroll a view inside NestedScrollView to top of the screen how

264 Views Asked by At

I have a NestedScrollView contains LinearLayout with orientation vertical, i have adding multiple views programmatically to the linearLayout, after that i need to click on a specific view inside the nestedScrollView and when clicking i need to make the view scrolling to the top of the screen. i used this but it doesnt work

   val scrollTo: Int = groupView.bottom //groupView is the view i clicked on and i need to scroll it to the top of the screen
   nestedSctollView.smoothScrollTo(0, scrollTo)
1

There are 1 best solutions below

5
Umesh P On

try this.

 mNestedScrollView.fullScroll(View.FOCUS_UP);