placing Item over WebView in Android
Unsolved
Mobile and Embedded
-
hello,
so we all know, that once I use WebView on Android, then its always topmost with no options to put anything over it...
however, we must have some options...AI offered 3 options:
use Dialog{} or Popup{} which will get topmost- it doenst- Use a FrameLayout: Place your WebView inside a FrameLayout and then add the overlay view as a sibling to the WebView. This way, the overlay view can be positioned above the WebView:
<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent" /> <View android:id="@+id/overlay" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#80000000" /> <!-- Semi-transparent overlay --> </FrameLayout>
- Custom WebView: Create a custom WebView by extending the WebView class and overriding the onDraw method to draw your overlay:
public class CustomWebView extends WebView { private Paint paint = new Paint(); public CustomWebView(Context context) { super(context); init(); } public CustomWebView(Context context, AttributeSet attrs) { super(context, attrs); init(); } private void init() { paint.setColor(Color.parseColor("#80000000")); // Semi-transparent color } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawRect(0, 0, getWidth(), getHeight(), paint); // Draw overlay } }
do we know any other options? best just a QML so i dont need to go to Java/C++
however if there is no other option, can I kindly ask you guys for the example step by step to make option 2 or 3 happen? I have never used Java or the XML layout, I work only with c++ and QML