<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
>
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/content"
/>
</ScrollView>
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ScrollView scrollView = (ScrollView)findViewById(R.id.scrollView);
textView = (TextView)findViewById(R.id.content);
scrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_MOVE : {
//顶部状态
if (scrollView.getScaleY() <= 0) {
Log.i("Main", "顶部");
}
//底部状态
if (scrollView.getChildAt(0).getMeasuredHeight() <= scrollView.getHeight()+scrollView.getScrollY()) {
Log.i("Main", "底部");
textView.append(getResources().getText(R.string.content));
}
}
break;
}
return false;
}
});
}
}