Scroll to the top of the judging:
getscrolly () = = 0
Scroll to the bottom to judge:
View Childview = getchildat (0);
Childview.getmeasuredheight () <= getscrolly () + getheight ();
Where Getchildat said to get ScrollView's child View
Childview.getmeasuredheight () indicates the height of the child view,
Getscrolly () means that the scroll distance of the y-axis is obtained,
GetHeight () is the height of the ScrollView
Getscrolly () When the maximum is reached, the height of the scrollview is equal to the height of its content.
There are two ways to determine where to slide:
1, implement Ontouchlistener to monitor whether to slide to the bottom
Ontouchlistener ontouchlistener=new Ontouchlistener () {
@Override
public boolean OnTouch (View V, motionevent event) {
Switch (event.getaction ()) {
Case MOTIONEVENT.ACTION_UP:
if (childview ! = null && childview . Getmeasuredheight () <= getscrolly () + getheight ()) {
} else if (getscrolly () = = 0) {
}
Break
}
return false;
}
}
2, rewrite the method of ScrollView onscrollchanged, in the onscrollchanged function to judge
public class Myscrollview extends ScrollView
{
Public Myscrollview (Context context)
{
Super (context);
}
Public Myscrollview (context context, AttributeSet AttributeSet)
{
Super (Context,attributeset);
}
@Override
protected void onscrollchanged (int l, int t, int oldl, int Oldt)
{
View view = (view) Getchildat (Getchildcount ()-1);
int d = View.getbottom ();
D-= (GetHeight () +getscrolly ());
if (d==0)
{
You is at the end of the list in ScrollView
Do-what-wanna do here
}
Else
Super.onscrollchanged (L,t,oldl,oldt);
}
}
This article welcome reprint, Reprint please indicate the source and the author
Source: Http://blog.sina.com.cn/staratsky
Meteor
Android Development Group, share the solutions and experience of problems in development, welcome everyone to join, group number: 293872059
How to judge the ScrollView of Android sliding to the bottom?