У меня есть LinearLayout (вертикальный), инкапсулированный в ScrollView. LinearLayout загружается динамически, и я хочу загрузить больше данных, когда нижняя страница страницы будет достигнута после прокрутки.android linear layout: y и height никогда не соответствуют (onScrollChanged)
Чтобы знать, когда нижняя страница будет достигнут, я перекрытый метод ScrollView.onScrollChanged():
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();
}
}
}
Неприятность состоит в том, что «у» значение всегда (пока) меньше, чем высота LinearLayout.
Почему? Спасибо.
Возможно, вам стоит использовать это? [Ответить] [1] [1]: http://stackoverflow.com/questions/10316743/detect-end-of-scrollview –