I have a LinearLayout (vertical) encapsulated in a ScrollView. The LinearLayout is load dynamically, and I want to load more data when page bottom is reached after scrolling.
To know when the page bottom is reached, I overrided ScrollView.onScrollChanged() method :
public class VerticalScrollView extends ScrollView {
private IVerticalScrollListener listener;
private LinearLayout list;
public VerticalScrollView(Context context, AttributeSet attributes) {
super(context, attributes);
}
public void setListener(IVerticalScrollListener listener) {
this.listener = listener;
}
@Override
protected void onScrollChanged(int x, int y, int oldx, int oldy) {
super.onScrollChanged(x, y, oldx, oldy);
if (list == null) {
list = (LinearLayout) findViewById(R.id.list);
}
final int bottom = list.getMeasuredHeight();
if (y >= bottom) { //never occures
listener.onPageBottomReached();
}
}
}
The trouble is that the "y" value is always (far) less than LinearLayout height.
Why ? Thank you.