-1
我只想在用戶滾動到某個位置時調用一個函數。目前,我做了以下內容:如何僅在滾動到某個位置時調用函數?
view.addOnScrollChangeListener(){
int[] locA = v1.getLocationOnScreen(); // it gives x & y location
int[] locB = v2.getLocationOnScreen(); // it gives x & y location
if(locA[1] == threshold) callFunctionA();
if(locB[1] == threshold) callFunctionB();
}
問題是,它從來沒有要求callFunctionA() or callFunctionB
如果用戶滾動太快。如何解決這個問題?
您是否使用scrollview作爲滾動容器? – Krish
是的,v1和v2是滾動視圖內的視圖 – jquery404
您可以將兩個視圖添加到recyclerview並獲取滾動位置 –