如何使用requestChildFocus平滑滚动到聚焦的视图?

时间:2018-08-21 09:51:40

标签: android android-animation

我在ScrollView中有一个childView,它扩展了onClick。我使用以下代码在屏幕上完全显示了展开的视图。

scrollView.requestChildFocus(childView, focussedView);

但是滚动不平滑。我该怎么做才能使滚动平滑?

1 个答案:

答案 0 :(得分:0)

您可以使用smooth scroll提供的ScrollView方法。这是documentation

尝试以下方法:

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.
相关问题