2013-07-04 60 views
0

在我的应用程序中,我有一个滚动视图与n个数据列出。有两个按钮被命名为UP,位于滚动视图上方,另一个按钮位于滚动视图下方。 使用UP and DOWN buttons the list of views can be scrolled.安卓支票要么滚动视图滚动或不滚动

scroll bar is in top the Up button will be invisible并且当scroll bar reaches the bottom the DOWN button will become invisible,我已经写逻辑此使用getScrollX()方法。

现在我的问题是,当例如3的数据非常少,the scroll bar will not be visible and the layout cannot be scrolled, in such a case both the UP and DOWN buttons need to be in invisible。如何做到这一点,请给我一个方法?

回答

0

您可以尝试和使用ViewTreeObserver检查ScrollView中的View的尺寸。如果尺寸超过某个限制(例如屏幕尺寸),则ScrollView将可滚动。有关更多详细信息,请参阅此preview SO answer。希望有所帮助!