2013-07-04 61 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。希望有所幫助!