Nataraj KR
Nataraj KR

Reputation: 1102

How to make smooth scroll to the view focused using requestChildFocus?

I have a childView inside ScrollView which expands onClick. I used the below code to bring the expanded view fully in the screen.

scrollView.requestChildFocus(childView, focussedView);

But the scroll is not smooth. What can I do to make the scroll smooth?

Upvotes: 0

Views: 1182

Answers (1)

Marc Estrada
Marc Estrada

Reputation: 1667

You could use the smooth scroll methods provided by ScrollView. Here is the documentation.

Try these methods:

public void setSmoothScrollingEnabled(boolean smoothScrollingEnabled)
// Set whether arrow scrolling will animate its transition.

public final void smoothScrollTo(int x, int y)
// Like scrollTo(int, int), but scroll smoothly instead of immediately.

public final void smoothScrollBy(int dx, int dy)
// Like View.scrollBy(int, int), but scroll smoothly instead of immediately.

Upvotes: 1

Related Questions