I am using WebView
to display a webpage having text as well as video content.
It loads & display video correctly as expected.
But when I go to full screen view of video ( I implemeted full screen video view as given here ) and then come back to WebView
, WebView
autoscroll in some amount.
How can I fix that?
Please suggest some idea/link.
I am using a compatible ScrollChangedListener already. So I've decided to scroll the view back in this listener during a period after onHideCustomView.
webview:
public interface OnScrollChangedListener {
void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY);
}
public void SafeScrollTo(int x, int y) {
OnScrollChangedListener mScrollChanged = mOnScrollChangeListener;
mOnScrollChangeListener =null;
scrollTo(x, y);
mOnScrollChangeListener =mScrollChanged;
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if(mOnScrollChangeListener !=null)
mOnScrollChangeListener.onScrollChange(this,l,t,oldl,oldt);
}
public void setOnScrollChangedListener(OnScrollChangedListener onSrollChangedListener) {
mOnScrollChangeListener =onSrollChangedListener;
}
OnScrollChangedListener mOnScrollChangeListener;
Activity:
mWebview.setOnScrollChangedListener((v, x, y, oldx, oldy) -> {
ArticleWebView webview = (ArticleWebView) v;
if(CustomViewHideTime>0 && System.currentTimeMillis()-CustomViewHideTime<350){
webview.SafeScrollTo(oldx, oldy);
return;
}});
WebChromeClient:
@Override
public void onHideCustomView() {
CustomViewHideTime = System.currentTimeMillis();
//todo delay and set CustomViewHideTime to 0
}
This can work just fine.
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