webview中有个computeVerticalScrollRange方法,是protected的,可以用反射,也可以自己写一个view继承webview,实现computeVerticalScrollRange方法,在需要滚动到底部的地方调用这个方法,然后scrollto即可
package com.carey.common;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.webkit.WebView;
/**
* 自定义WebView
*
* @version
* @author zhengyx 2015-4-16 上午11:17:56
*
*/
public class CustomWebview extends WebView {
/**
* Comments for <code>TAG</code>
* TAG
*/
private static final String TAG = "mywebview";
/**
* CustomWebview 构造器
*
* @param context
* @param attrs
*/
public CustomWebview(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* CustomWebview 构造器
*
* @param context
*/
public CustomWebview(Context context) {
super(context);
}
/**
* 计算纵向范围,用于滚动到底部
*
* (non-Javadoc)
* @see android.webkit.WebView#computeVerticalScrollRange()
*/
@Override
protected int computeVerticalScrollRange() {
int computeVerticalScrollRange = super.computeVerticalScrollRange();
Log.i(TAG, "computeVerticalScrollRange" + computeVerticalScrollRange);
return computeVerticalScrollRange;
}
}