Embedding a custom view inside a WebView

I have a custom view that I would like to embed in a WebView.

By embedding, I mean:

  • Custom view captures onTouch events in its area
  • The custom view looks like part of a web page, so it scrolls with the surrounding text

I wrote a custom view, so I can edit it as needed

+7
source share
2 answers

as I said in my comment.

I can’t think of a normal path to what you are doing. What I would do if I were you is to put a custom view between 2 WebView objects like this:

 <ScrollView android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <WebView android:id="@+id/webView1 ... /> <include android:layout="custom_layout" /> <WebView android:id="@+id/webView2 ... /> </ ScrollView> 
+1
source

Take RelativeLayout or FrameLayout as the parent. then put the webview as the first child layout and then your customview as the second child view.

After that, put some code to show and hide the CustomView for a specific action.

This will help you.

Enjoy. :)

+1
source

All Articles