I had to do it myself in order to display the βI Agreeβ button as soon as the user scrolled to the bottom of the EULA. Lawyers, huh?
In fact, when you override WebView (and not ScrollView, as in the answer from @JackTurky), you can call getContentHeight () to get the height of the content, rather than getBottom (), which returns the visible bottom and is not useful.
This is my complete solution. As far as I can see, these are all Level 1 APIs, so it should work anywhere.
public class EulaWebView extends WebView { public EulaWebView(Context context) { this(context, null); } public EulaWebView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public EulaWebView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public OnBottomReachedListener mOnBottomReachedListener = null; private int mMinDistance = 0; public void setOnBottomReachedListener(OnBottomReachedListener bottomReachedListener, int allowedDifference ) { mOnBottomReachedListener = bottomReachedListener; mMinDistance = allowedDifference; } public interface OnBottomReachedListener { void onBottomReached(View v); } @Override protected void onScrollChanged(int left, int top, int oldLeft, int oldTop) { if ( mOnBottomReachedListener != null ) { if ( (getContentHeight() - (top + getHeight())) <= mMinDistance ) mOnBottomReachedListener.onBottomReached(this); } super.onScrollChanged(left, top, oldLeft, oldTop); } }
I use this to display the "I Agree" button when the user scrolls to the bottom of the WebView, where I call it that (in a class that "implements OnBottomReachedListener":
EulaWebView mEulaContent; Button mEulaAgreed; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.eula); mEulaContent = (EulaWebView) findViewById(R.id.eula_content); StaticHelpers.loadWebView(this, mEulaContent, R.raw.stylesheet, StaticHelpers.readRawTextFile(this, R.raw.eula), null); mEulaContent.setVerticalScrollBarEnabled(true); mEulaContent.setOnBottomReachedListener(this, 50); mEulaAgreed = (Button) findViewById(R.id.eula_agreed); mEulaAgreed.setOnClickListener(this); mEulaAgreed.setVisibility(View.GONE); } @Override public void onBottomReached(View v) { mEulaAgreed.setVisibility(View.VISIBLE); }
So, when the bottom is reached (or in this case, when they fall into 50 pixels), the button "I agree" appears.