简体   繁体   English

如何以编程方式创建透明活动?

[英]How to create a transparent Activity programmatically?

I want to launch an Activity with a webView as its content from current Activity. 我想使用webView作为当前Activity的内容启动一个Activity。 This new activity needs to be transparent and webview should be in the center. 这项新活动需要透明,webview应该是中心。 I looked around the web but only solutions I found were using style xmls. 我环顾网络,但我找到的解决方案只使用了风格xmls。 I want to do it using pure code ie no xml declarations. 我想使用纯代码,即没有xml声明。 if anybody has come across this then please shed some light. 如果有人遇到过这个,那么请说清楚。

Have you considered creating a Dialog with a WebView embedded in it? 您是否考虑过在其中嵌入WebView创建一个Dialog?

EDIT Here is what I have in my onCreateDialog() : 编辑这是我在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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM