public class CusWebView extends WebView {
public CusWebView(@NonNull Context context) {
super(context);
}
public CusWebView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public CusWebView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
// webview的高度
float webcontent = getContentHeight() * getScale();
/*view的高度*/
float height = getHeight();
/*内容滑动百分比*/
int percent = (int) (t/ (webcontent - height)*100);
}
}
网友评论