如何在滚动时显示视图并在android中滚动停止后隐藏视图

时间:2014-04-08 14:12:56

标签: android view scrollview show-hide

我有一个线性布局视图,在我的布局底部有一些按钮。布局包含很多元素,所以我添加了scrollview来显示所有内容。

现在当我向上或向下滚动时,我想要隐藏我的底部线性布局内容,并且一旦用户停止滚动listview,我想再次显示它。

任何人都可以建议我实现这个目标。 任何帮助都是适当的 感谢

1 个答案:

答案 0 :(得分:1)

您可以尝试实施OnScrollListener的{​​{1}}。它有一个方法:

ScrollView

当滚动状态发生变化时,您可以 /** * Callback method to be invoked while the list view or grid view is being scrolled. If the * view is being scrolled, this method will be called before the next frame of the scroll is * rendered. In particular, it will be called before any calls to * {@link Adapter#getView(int, View, ViewGroup)}. * * @param view The view whose scroll state is being reported * * @param scrollState The current scroll state. One of {@link #SCROLL_STATE_IDLE}, * {@link #SCROLL_STATE_TOUCH_SCROLL} or {@link #SCROLL_STATE_IDLE}. */ public void onScrollStateChanged(AbsListView view, int scrollState); 转到要显示/隐藏的setVisibility()