I have a WebView
and a native custom view I want to add underneath the WebView
. I've tried wrapping the WebView
inside a ScrollView
, and while that does exactly what i want, the scrolling performance is really laggy and if a user flings the scroll tapping the screen does not stop the fling like it should.
The other approach I was thinking was to inflate the WebView
into a wrapper FrameLayout
with my footer view on top of the WebView
, then somehow extend the WebView
height to accomodate the footer size, push the footer view to the end of the WebView
s height and then monitor the scroll of the WebView
to move the footer with it.
I've setup the base class, my problem is extending the scrollable content in the WebView
, and then pushing the footer to the bottom of the WebView
s content; the main issue being that WebView
isn't your typical android view and the page content load asynchronously (and thus the content size changes).
How can I extend the scrollable content of a WebView
? And how can I set the native footer below the WebView
content?
EDIT:
I don't actually use xml, the view is constructed in code like so:
public class WebViewWithFooter extends FrameLayout {
private ObservableWebView mWebView;//webview with scroll methods overridden for access
private FrameLayout mFooterContainer;
public WebViewWithFooter(Context context) {
super(context);
init();
}
public WebViewWithFooter(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public WebViewWithFooter(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public WebViewWithFooter(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
private void init() {
FrameLayout.LayoutParams footerParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
FrameLayout.LayoutParams webviewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
mWebView = new ObservableWebView(getContext());
mFooterContainer = new FrameLayout(getContext());
addView(mWebView, webviewParams);
addView(mFooterContainer, footerParams);
}
}