开发者

How to create a transparent Activity programmatically?

开发者 https://www.devze.com 2023-01-09 00:49 出处:网络
I want to launch an Activity with a webView as its content from cur开发者_Go百科rent Activity. This new activity needs to be transparent and webview should be in the center. I looked around the web bu

I want to launch an Activity with a webView as its content from cur开发者_Go百科rent Activity. This new activity needs to be transparent and webview should be in the center. I looked around the web but only solutions I found were using style xmls. I want to do it using pure code i.e. no xml declarations. if anybody has come across this then please shed some light.


Have you considered creating a Dialog with a WebView embedded in it?

EDIT Here is 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);
0

精彩评论

暂无评论...
验证码 换一张
取 消