How to create transparent activity programmatically?

I want to start an Activity with a webView as its contents from the current Activity. This new activity should be transparent, and web browsing should be in the center. I browsed the web, but only the solutions I found used the xmls style. I want to do this using clean code, i.e. No xml ads. if anyone comes across this, please shed some light.

+3
source share
1 answer

Do you consider creating a dialog box with a built-in WebView?

EDIT Here's what I have in my onCreateDialog():

Dialog d = new Dialog(MainFloatOver.this);
LinearLayout mLinearLayout = new LinearLayout(this);
mLinearLayout.setBackgroundColor(android.R.color.transparent);
LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
mLinearLayout.setLayoutParams(llp);
d.setContentView(mLinearLayout);
WebView mWebView = new WebView(this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("www.google.com");
mLinearLayout.addView(mWebView);
+2
source

Source: https://habr.com/ru/post/1756966/


All Articles