用例:
I am writing code for browser, in that I want to display WebView
content inside a PopupWindow. That is WebView should not be part of
MainApplication window.
细节:
- WebView 可以放置在 android Dialog 中(已经测试过),但问题是 Dialog 将成为 MainApplication 窗口的一部分,尽管它看起来像用户的单独窗口。
- 使用 PopupWindow,WebView 会显示片刻,然后消失。
弹出窗口布局详细信息如下
{
popUp = new PopupWindow(this);
layout = new LinearLayout(this);
mainLayout = new LinearLayout(this);
but = new Button(this);
but.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
popUp.showAtLocation(mainLayout, Gravity.CENTER, 10, 10);
popUp.update(0, 0, 1280, 1024);
}
}
flayout = new FrameLayout(this);
mwebview = new WebView(this);
flayout.addView(mwebview);
params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
layout.addView(flayout, params);
popUp.setContentView(layout);
mainLayout.addView(but, params);
setContentView(mainLayout);
=== webview init done here===
}
真的需要你的建议。