I need some help to get my custom webView CONTENT height, please check below is my code
webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int displayHeight = webView.getHeight();
final int contentRange = webView.getContentHeight();
final int y = v.getScrollY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d("Get webView height ", "" + displayHeight); // Result : 528
Log.d("Get webView content height ", "" + contentRange); // Result : 2112
Log.d("Get webView content scroll top ", "" + y);
return false;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_MOVE:
}
return false;
};
Above is my code to get my custom webView content height with webview.setOnTouchListener, that code is work.
But, now I want to get my custom WebView content height from button click, that does not work, what I got is always get a height of my webView not the content height, below my code for button click
Button btn = (Button) this.getActivity().findViewById(R.id.btnCLick);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int webViewContentHeight = webView.getContentHeight();
Log.d("Get my custom webView content height", " " + webViewContentHeight); // Result : 528
}
});
Much appreciate if I can have a detailed procedure, thanks.