簡體   English   中英

如何檢測視圖有多少滾動ScrollView

[英]How to detect how much the view has scroll ScrollView

如何檢測滾動視圖滾動了多少?

您需要重寫ScrollView的onScrollChanged()方法:

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {

    Log.i(TAG, "View onScrollChanged");
    View view = (View) getChildAt(getChildCount() - 1);
    int diff = (view.getBottom() - (getHeight() + getScrollY()));// Calculate

    super.onScrollChanged(l, t, oldl, oldt);
}

在這里, diffScrollView底部邊緣與底部當前可見內容之間滾動的剩余空間。 diff = 0ScrollView已完全向下滾動。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM