I am trying to create a view which is filled with a webview taking up the whole screen.
On top of that webview I need to place a button which remains even if the user navigates with the webview links. The webview should be visible behind the button which is why I can't simply place the button below the webview.
I've managed to get my custom button on top of the webview using canvas and the touch input event but this has disabled input to the webview. To further complicate things I can't use standard Android resources. I must use the assets folder and base view.
Basically I have a view (CustomWebView extends View) which contains a webview. I have a custom button derived from view which is drawn on top of the webview using canvas and accepts input with the touch event defined in my custom button class (checking if touch x, y is within button bounds). I believe I have set the view layout params correctly so it should not simply be covering the webview and input to the webview works if I draw - but don't look for input to - the button.
I know this probably all seems a bit crazy but unfortunately due to the ridiculous nature of the project I have to do it this way. Any ideas why the webview input might be disabled by drawing a separate view on top of it? Any ideas how I could get around this?
I have read the Android docs extensively and se开发者_Go百科arched many forums but this one escapes me. Thanks for any help or insights you may be able to provide.
Hmm. Not sure I fully understand what you are after but cant you solve this by just using a RelativeLayout where the button is placed on top of the webview?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is a button"
/>
</RelativeLayout>
精彩评论