guys! I have googled a whole day,still,I can not find a solution.So, I post my question here,hope to get some hit.
I want to add some blank area at the end of a webview in android, I try to set the bottom padding of webview,however, it doesn't work. I know the layout of webview is absoluteLayout,which is deprecated, and I tried get the whole length of webview,and add a view at the end, I try to use getContentHeight(), however, the height is not quite correct, it is not end of webview,maybe because of picture or something else, I do not know.
So,my question is,is there anyway to achieve my original goal, which is add some blank area at the end of a webview?
Thanks in advance!
I did something similar before, but I think it should work.
Create a custom class that Extend the Webview (say CustomWebView)
Override onMeasure
e.g.
public void onMeasure(int wspec, int hspec){
super.onMeasure(wspec, hspec);
this.setMeasuredDimension(this.getMeasuredWidth(), this.getMeasuredHeight() + 200); // the padding you need.
}
After two days google and trying, I finally get what I want, thanks xandy,your method do give me a hit.
Here is my solution. I did not override OnMeasure method, instead , I override computeVerticalScrollRange method, so ,it will increase the whole vertical length of webview . Just like add some blank area at the end.
the following is my code:
protected int computeVerticalScrollRange() {
float density = getResources().getDisplayMetrics().density;
return super.computeVerticalScrollRange()+(int)(60*density);
}
Thanks again xandy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With